Directory.Exists not working for a network path

后端 未结 4 1706
春和景丽
春和景丽 2020-12-10 11:02

I have a line of code checking if a directory exists and then getting the list of files in it.

System.IO.Directory.Exists(@\"\\\\Server\\Folder\\\");
         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 11:06

    I may be a little late, but i've found that there is a problem on this method of the Directory class. Instead i've used DirectoryInfo with impersonation this way:

    new DirectoryInfo(path).Exists
    

    This way you avoid the whole identity change problem, which was denied by our IT area.

    I hope this helps somebody!

提交回复
热议问题