开发者

VB check inside a folder to see if there are files

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜