locked
System.IO.IOException: The network name cannot be found RRS feed

  • Question

  • I have an asp.net project that is running on the sharepoint server as an application pool. I am attempting to upload a pdf file to a sharepoint folder using filestream. I am getting this error:

    System.IO.IOException: The network name cannot be found.

    I am assuming it has something to do with the permissions on the sharepoint folder. It works fine on the client side when running from VS so I at least know the path is valid.

    I have given Contribute access to the folder to myself and the account that is running the application pool. I am unsure of what else I need to do. Or is it related to something other than security/permissions?

    Here is a screenshot of the error:

     

    Thursday, May 2, 2019 7:31 PM

All replies

  • Hi,

    Please try to go to the export folder. Share it out. Give the identity of your application (if its a web site, use the app pool identity. 

    And try to replace the folder path with below.

    http://server-name/path

    To upload file to SharePoint folder, we use Server Object Model to achieve it.

    https://blogs.msdn.microsoft.com/peterj/2008/01/23/creating-folders-and-adding-files-to-sharepoint-document-library/

    https://www.c-sharpcorner.com/blogs/programatically-add-file-in-folder-in-sharepoint-document-library1

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, May 3, 2019 3:23 AM
  • That path does not work. I get the error that URI paths not supported.

    "Give the identity of your application (if its a web site, use the app pool identity."

    Do you mean give the application pool access to the folder? When I go to grant permissions it does not find the app pool name.

      

    Friday, May 3, 2019 4:27 PM
  • Can you post a stack trace of the error so that the problem can be identified further? Usually, the stack trace can be found in the source HTML code of the "Server Error in '/' Application." error page, if not otherwise shown directly on the page display window.

    • Edited by DanPinGF Saturday, May 4, 2019 1:38 AM Delete part of text
    Saturday, May 4, 2019 1:36 AM
  • Hi,

    Please try to use Admin user to check if it works.

    And use server object model to upload files to SharePoint library.

    Or you can provide the complete code in use if possible or more information about this issue, which should make the issue easier to be researched.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, May 6, 2019 7:16 AM
  • Hi,

    Would you please provide us with an update on the status of your issue?

    Best Regards,
    Dennis

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thursday, May 9, 2019 8:44 AM
  • Hmm, the System.IO.IOException error doesn't seem to be related to the permissions. I suspect some other misconfiguration of your SharePoint server. So, you might want to dig into your Web.Config file to pinpoint the issue.
    Tuesday, May 14, 2019 2:37 AM
  • Sorry for the delay. I am working on multiple projects and just got back on this.

    Here is the Stack Trace:

    Stack Trace:

    [IOException: The network name cannot be found.
    ]
       System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +1494
       System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1118
       System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +130
       System.IO.FileStream..ctor(String path, FileMode mode) +109
       PatientSurvey.frmRpts_DsgSurvey_Cons.generate_report(String facnum, String facname) in \\mfa-file1\ISSWFILES\VBProjectsCode\PatientSurvey\PatientSurvey\frmRpts_DsgSurvey_Cons.aspx.cs:1156
       PatientSurvey.frmRpts_DsgSurvey_Cons.PrintAllRpts_Click(Object sender, EventArgs e) in \\mfa-file1\ISSWFILES\VBProjectsCode\PatientSurvey\PatientSurvey\frmRpts_DsgSurvey_Cons.aspx.cs:367
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +129
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +141
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4949

    Friday, May 17, 2019 8:21 PM
  • Hi,

    I suggest you provide the complete code in use if possible, which should make the issue easier to be researched.

    Did you try to use Server Object Model to achieve it?

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, May 22, 2019 8:52 AM
  • Not sure what you mean by Server Object Model.

    Here is the code:

                   ReportViewer1.LocalReport.SetParameters(reportParameters);

                    Warning[] warnings;
                    string[] streamids;
                    string mimeType;
                    string encoding;
                    string fileNameExtension;

                    byte[] bytesret;
                    bytesret = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streamids, out warnings);

                        using (FileStream fs = new FileStream(exportrptpath, FileMode.Create))
                        {
                            fs.Write(bytesret, 0, bytesret.Length); 
                        }

    Friday, May 31, 2019 8:26 PM
  • Hi,

    The server object model code like below.

    SPSite site = new Microsoft.SharePoint.SPSite("http://localhost");            
    SPWeb spWeb = site.RootWeb;
    
    SPList docLib = spWeb.Lists["My Document Library"];          
    SPListItem folder = docLib.Folders.Add(docLib.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, "My folder");
    folder.Update();
    
    using (FileStream fs = File.OpenRead (@"C:\TestDoc.doc"))
    {
               SPFile file = folder.Folder.Files.Add("TestDoc.doc", fs);
               file.Update(); 
    }

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, June 3, 2019 2:18 AM