简体   繁体   English

将文件上传到C#中的网络映射驱动器

[英]upload file to the network mapped drive in c#

I am using c# asp.net mvc 3 and entity framework to upload the file to the network drive mapped as Z drive. 我正在使用c#asp.net mvc 3和实体框架将文件上传到映射为Z驱动器的网络驱动器。 I have following c# code for determining file path: 我有以下C#代码来确定文件路径:

var path = Path.Combine(Z:/upload/catone/", fileName);
aries.SaveAs(path);

I am using window server 2008 and IIS 7. I have also check Security of upload folder of network drive and have acess full control for EVERYONE user. 我使用的是Window Server 2008和IIS7。我还检查了网络驱动器上载文件夹的安全性,并对所有人进行了完全控制。 If I changed file path to local drive, it works fine. 如果我将文件路径更改为本地驱动器,则可以正常工作。 But it shows following error while uploading to network drive (Z:/). 但是在上传到网络驱动器(Z:/)时显示以下错误。

Could not find a part of the path 
'Z:\upload\catone\_2013011504265221N_todaily.wav'.

Your code is running under IIS and thus is run with access privileges of the IIS user account which may not have access to that network drive. 您的代码在IIS下运行,因此以可能无法访问该网络驱动器的IIS用户帐户的访问权限运行。

You can try runnning the app pool under your identity for instance, to rule this issue out, or give full access to the group IIS_IUSRS to that folder. 例如,您可以尝试以您的身份运行应用程序池,以排除此问题,或将IIS_IUSRS组的完全访问权限授予该文件夹。

First of all save the file in local machine , than after use file.copy(Source, Destination, true) method to save file in network drive. 首先将文件保存在本地计算机中,然后使用file.copy(Source,Destination,true)方法将文件保存在网络驱动器中。

try that it is helpful for you 尝试对您有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM