I am trying to get my vb.net application to look inside a folder on the web server and then let me know whethe开发者_如何学JAVAr there are files in there or if the folder is empty...Would anybody know where i would begin? Thanks
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()
.
I would suggest you have a look at Directory.GetFiles
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.
精彩评论