how to check if a directory contains any files or not?if files exist how to delete them in vb?
ramabala
0
Newbie Poster
Recommended Answers
Jump to PostPrivate Sub RemoveDir(ByVal _path As String) For Each mDir As String In IO.Directory.GetDirectories(_path) My.Computer.FileSystem.DeleteDirectory(mDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Next End Sub
if the given path has no content then ofc not get deleted
Jump to Postthen u can do:
if IO.File.exist("path and file here") then io.file.delete("path and file here") end if
Jump to Postso now im confused....
what exactlly you want? just empty a directory without removing the directory? but then i dont understand why you wanna check if a file exist if u dont know the name o.O
All 11 Replies
GeekByChoiCe
152
Practically a Master Poster
Featured Poster
ramabala
0
Newbie Poster
GeekByChoiCe
152
Practically a Master Poster
Featured Poster
ramabala
0
Newbie Poster
ramabala
0
Newbie Poster
GeekByChoiCe
152
Practically a Master Poster
Featured Poster
sknake
1,622
Senior Poster
Featured Poster
ramabala
0
Newbie Poster
sknake
1,622
Senior Poster
Featured Poster
ramabala
0
Newbie Poster
sknake
1,622
Senior Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.