Search code examples
c#asp.netnetwork-drive

How to store Files on Shared network drive in c#


I have a Asp.net Application where i am attempting to save my files on a shared network drive.

 StrPath = HttpContext.Current.Server.MapPath(@"\\server\c\DTA\");

But i get an error unable to find path

What should be done is it possible to save files in a shared network drive


Solution

  • MapPath is used to map a virtual path of your webserver to a physical path on the hard drive. What you have is already a physical path, so you can just use it to create the file directly.

    var fileStream = File.Create(@"\\server\c\DTA\");
    ...