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\test.com.au\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\test.com.au\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)
    FileUpload1.PostedFile.InputStream.Dispose()

    Thank You in advance
  • #768342
    Hi,

    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

    Thanks,
    Mani

  • #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.
    Server.MapPath("~/Sample/Uploads/").

    Thanks

  • #768460
    Hi,

    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.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #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
    Thanks
    Koolprasd2003
    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
    <configuration>
    <system.web>
    <httpRuntime maxRequestLength="307200" />
    </system.web>
    <system.webServer>
    <security>
    <requestFiltering>
    <requestLimits maxAllowedContentLength="314572800" />
    </requestFiltering>
    </security>
    </system.webServer>
    </configuration>

    2) If possible then can you please try with following approach once
    HttpContext.Current.Server.MapPath(@"../Attachment");

    Debasmit Samal


  • Sign In to post your comments