You must Sign In to post a response.
  • Category: .NET

    File not found error in 'C:\inetpub\wwwroot\ folder

    Hi All,

    Here I pasted the path of my application in inetpub.
    C:\inetpub\wwwroot\My Applications\\Application\Sample\Uploads\

    In the following code I try to upload file to ~/Sample/Uploads/, but I get error saying

    "Could not find file 'C:\inetpub\wwwroot\My Applications\\Application\Sample\Uploads\file.pdf'. "

    Dim FileSize As Integer = FileUpload1.PostedFile.ContentLength
    'If FileSize < 6291456 Then
    Dim Path As String = Server.MapPath("~/Sample/Uploads/")
    'Dim FileName As String = FileUpload1.FileName
    Dim FileName As String = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName)

    'FileName = FileUpload1.FileName
    Session("FileName") = FileName
    FileUpload1.SaveAs(Path & FileName)

    Thank You in advance
  • #768342

    Did you check you have access for picking file in C: Folder.

    usually File permission will give you this errors when you try to pick some file or read/write something in file particular in C: Folder.

    Kindly to check this do some work around. Put your folder some where in D: folder and change the coding to the same path. Then try to connect that, If that connects then it should the folder permission issue else if it gives same issue then we need to look into code level


  • #768345
    Hi Mani,

    Thank you very much for your response. I was wondering whether following line is the right way to save file in specified directory.


  • #768460

    Have you debug the code and seen whether did you get the exact file path over there and the file is available in the specified file path? If yes then no worries else you get this type of errors?

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #768461
    Have you upload file in that path ? which line gives you error ? please elaborate so that we can help you better in order to get it resolved
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #768504
    Your approach is correct. Sometimes this exception comes due to MaxRequestLength exception.
    Please try once with following. e.g if your file size is 300 MB then config file setting should be like below
    <httpRuntime maxRequestLength="307200" />
    <requestLimits maxAllowedContentLength="314572800" />

    2) If possible then can you please try with following approach once

    Debasmit Samal

  • Sign In to post your comments