Reputation: 29533
I am trying to get my vb.net application to look inside a folder on the web server and then let me know whether there are files in there or if the folder is empty...Would anybody know where i would begin? Thanks
Upvotes: 0
Views: 20896
Reputation: 498914
Use the DirectoryInfo.EnumerateFiles()
method.
Dim myDir as DirectoryInfo = new DirectoryInfo(pathToDir)
If (myDir.EnumerateFiles().Any())) Then
' Got files in direcotry!
End If
If you are also interested in finding out if there are directories within this one, there is also DirectoryInfo.EnumerateDirectories()
.
Upvotes: 4
Reputation: 887275
If your program is running on the web server, you can simply check whether Directory.GetFileSystemEntries(path)
returns anything.
If your program is running on a client, you'll need to make a server-side script that calls Directory.GetFileSystemEntries
and returns a value to the client.
Upvotes: 0