我正在尝试在远程机器上创建一个文件,但我收到“找不到网络名称”。我检查了网络路径,并且能够从我的机器访问该路径。你能告诉我有什么问题吗?
这是我的代码。
using (StreamWriter sw = new StreamWriter("\\\\servername\\TEST1\\TEST\\NEWFILE.csv", true))
{
sw.WriteLine(sw);
}
我正在尝试在远程机器上创建一个文件,但我收到“找不到网络名称”。我检查了网络路径,并且能够从我的机器访问该路径。你能告诉我有什么问题吗?
这是我的代码。
using (StreamWriter sw = new StreamWriter("\\\\servername\\TEST1\\TEST\\NEWFILE.csv", true))
{
sw.WriteLine(sw);
}
Go to \servername\TEST1 and give write permission to the user or aspnet (if you have a web application) on test folder and then re-run your program. It will work.
To give write permissions, just refer to this article:
How to share a folder/File
In case it still does not work, replace servername with server IP address and do the same as stated above.
这肯定是一个安全问题。您需要授予远程计算机的写入权限
向运行此应用程序的用户授予访问权限,它是 IIS 池或 Windows 服务等