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

前端 未结 4 466
渐次进展
渐次进展 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: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

提交回复
热议问题