Is there any alternative for System.IO.DirectoryInfo.Exists

前端 未结 4 420
渐次进展
渐次进展 2021-01-24 02:19

The System.IO.DirectoryInfo.Exists always return false if i am giving a UNC like this \\\\192.168.0.33\\Others (F).

and it occurs only when I r

相关标签:
4条回答
  • 2021-01-24 03:03

    See How Can I Determine if a Folder Exists on a Computer?

    0 讨论(0)
  • 2021-01-24 03:10

    To access UNC file, you need to first connect to the network location by providing credentials and opening the connection to the network share, after that you can run DirectoryInfo.Exists

    Look into P/Invoke to WNetAddConnection2 / NetUseAdd and pass the username/password- then you should be able to access the file / folder info.

    Edit:

    Try this class I made to connect to UNC paths: http://www.mediafire.com/?77ae4ratoqa7s4b

    0 讨论(0)
  • 2021-01-24 03:20

    Try System.IO.Directory.Exists().

    0 讨论(0)
  • 2021-01-24 03:21

    It should work. My guess is that the account that your code is running under doesn't have access to the UNC path.

    0 讨论(0)
提交回复
热议问题