var di = new DirectoryInfo(Root);
var diList = di.GetDirectories();
访问位于网络上的文本路径“根”时,上述崩溃。我仅在用户首次登录 Windows 7 时发生(未在其他操作系统上测试)。如果用户使用 Windows Explorer 导航到指定路径,则 di 能够检索目录。
我知道可以做一个捕获并提示用户单击打开 Windows 资源管理器并导航到路径的链接,但我不是一个解决方法。我希望我的程序能够建立与网络路径的连接,而无需 Windows 资源管理器先执行此操作。
例外:
System.IO.IOException: The network name cannot be found.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path,string originalUserPath,
String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler,
Boolean checkHost)
at System.IO.DirectoryInfo.InternalGetDirectories(String searchPattern,
SearchOption searchOption) at Controls.ValidationControl.LoadDBox(Object sender,
RoutedEventArgs e)
in c:\Controls\ValidationControl.xaml.cs:line 1010
提前感谢您的支持,约翰