[英]Read/write files in shared drive from web application hosted on iis
We have two server in same domain. 我们在同一域中有两个服务器。 On one server (SERVER1) we have folder "C:\\AppFiles\\Production\\Inbound" and shared AppFiles folder as a drive (AppFiles (O:)) to another server (SERVER2) and we are manually able to place files in shared drive (O:\\Production\\Inbound) on SERVER2.
在一台服务器(SERVER1)上,我们有文件夹“ C:\\ AppFiles \\ Production \\ Inbound”,共享的AppFiles文件夹作为到另一台服务器(SERVER2)的驱动器(AppFiles(O :)),我们可以手动将文件放置在共享驱动器中(O:\\ Production \\ Inbound)在SERVER2上。 But we want to read/write files in shared drive (O:\\Production\\Inbound) from our mvc web application hosted on SERVER2.
但是我们想从SERVER2上托管的mvc Web应用程序读取/写入共享驱动器(O:\\ Production \\ Inbound)中的文件。
We are getting below error in provided code when try to read/write in shared drive (O:\\Production\\ 尝试在共享驱动器中读取/写入时,提供的代码中出现错误(O:\\ Production \\
public void Writefile()
{
System.IO.File.WriteAllText(Path.Combine(@"O:\Production\Inbound", "testlog.txt"), "test test, text");
}
error: 错误:
Could not find a part of the path 'O:\\Production\\Inbound\\testlog.txt'.
找不到路径“ O:\\ Production \\ Inbound \\ testlog.txt”的一部分。
Please suggest how i can read/write files in shared drive from application hosted on iis. 请建议我如何从iis上托管的应用程序读取/写入共享驱动器中的文件。
Mapped drives are not supported on IIS, rather you can use UNC paths. IIS不支持映射的驱动器,而是可以使用UNC路径。 Try changing the path to the following:
尝试将路径更改为以下内容:
\\SERVER1\C$\AppFiles\Production\Inbound
If both the servers are on the same network and you can access the above link from server 2, the it should work. 如果两个服务器都在同一网络上,并且您可以从服务器2访问上面的链接,则它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.