ASP.NET MVC3 Copy file to Shared Mapped Drive - Ac

2019-07-20 04:53发布

问题:

Currently I am getting this error when trying to copy a local file over to a shared network drive.
Access to the path '\\vlanxxxx\Vlanxxx\VT\12345.pdf' is denied'

Background Information

  • Running ASP.NET MVC3, Windows Server 2008 R2
  • In IIS->Application Pools my Application has the correct permission to access the shared drive
  • I have tried copying the file from a local folder to local folder and it worked successfully.
    i.e C:\log\12345.pdf -> C:\test\12345.pdf



Purpose: My overall purpose is to copy a file in my local server to a shared mapped network drive.

Q: Is this actually possible when using ASP.NET, is there any networked shared drive limitations when using this technology?

Code for copying the file over (I am pretty sure the code is fine, but here is the code incase)

String path = @"C:\log\12345.pdf";
String dest_path = @"\\vlanxxxx\Vlanxxx\VT\12345.pdf";
File.Copy(path, Path.Combine(dest_path, Path.GetFileName(path)));

Thank you for the help and assistance, I appreciate your time! Please let me know if there is any misunderstanding in the question. I will try to edit and clarify as soon as possible.

回答1:

In IIS, try to give write permission to the users IUSR and IIS_IUSR in that destination path / folder.