访问网络被拒绝 [英] Access to a network denied
本文介绍了访问网络被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用下面的代码,即使可以通过我的Windows资源管理器访问网络文件夹/文件,也拒绝使用网络驱动器。
Using the piece of code below, got denied to a network drive even though the network folders/files are accessible through my Windows Explorer.
using (System.IO.StreamReader sr = new System.IO.StreamReader(System.IO.File.OpenRead(@"\\netDrive\floder\SRID.txt"))) {
s = sr.ReadToEnd();
Console.WriteLine(s);
}
如何解决这个问题?谢谢。
How can this problem be solved? Thanks.
推荐答案
您可以要求用户输入用户名和密码,或直接将其传递给WNetAddConnection3等函数(参见link [ ^ ]了解更多详情。)
You can ask the user for a username and password, or directly pass those to a function like WNetAddConnection3 (see link[^] for more details).
这篇关于访问网络被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文