0

I'm trying to save a file in my server. When I was running my code locally it was saving just fine but now on the server isn't working and I'm getting this message.

Could not find a part of the path 'C:\inetpub\folderPath\fileName.jpg'

My code is:

[HttpPost]
    public string UploadFile() {
        var file = HttpContext.Current.Request.Files.Count > 0 ?
            HttpContext.Current.Request.Files[0] : null;
        var pathFOLDER = @"C:\inetpub\folderPath\" 
        if (file != null && file.ContentLength > 0) {
            var fileName = Path.GetFileName(file.FileName);
            var path = Path.Combine(
                pathFOLDER,
                fileName
            );

            file.SaveAs(path);
        }
    }

The problem is that the folder does exist. Some people said about permissions to save to the folder but i followed their steps and my problem wasn't solved. Is there an error in my code? Or how can I check if I have permission to save it or not?

MMidia
  • 13
  • 2
  • 1
    i suggest you read this https://stackoverflow.com/questions/17838914/c-sharp-save-files-to-folder-on-server-instead-of-local – Masoud Andalibi Aug 15 '17 at 21:02
  • I had a similar problem to this recently. The account running the app did not have access to the folder in question. – w0051977 Aug 15 '17 at 21:04

0 Answers0