none
Read mpp file inside a document library with C#.NET RRS feed

  • Question

  • I have the following piece of code to open a project file in a SharePoint 2013 event receiver. 

    ApplicationClass projectApp = new ApplicationClass();
    
                    projectApp.FileOpen(filePath, true, Missing.Value, Missing.Value, Missing.Value,
        Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
        PjPoolOpen.pjDoNotOpenPool, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

    This read the file well when the variable file path is assigned with a local path. eg: (@"D:\\test.mpp")

    But if I assign a SharePoint document library url where there is an actual document, it removes part of the url and say that file cannot be opened.

    Its a COMException and the error is as follows.

    {"The file \"//spapp/ProjectDocumentLibrary/test\" cannot be opened."}

    The actual value of the fileName variable by the time this is executed includes the http part and the .mpp extension. 

    Any thoughts on overcoming this?

    Tuesday, December 22, 2015 5:21 PM

Answers

All replies

  • Hi Malin,

    I tried to use the Project COM+ read a mpp file stored in SharePoint document library and the code works fine.

    I read the mpp file with file path like below:

                string Path = "http://sp/sites/test/Shared%20Documents/Project1.mpp";
                Microsoft.Office.Interop.MSProject.ApplicationClass app = new ApplicationClass();
                PjPoolOpen pool = PjPoolOpen.pjDoNotOpenPool;
                PjMergeType merge = PjMergeType.pjDoNotMerge;
                object ignoreReadOnlyRecommended = false;
                object readOnly = false;
                object missing = System.Reflection.Missing.Value;
                app.FileOpenEx(Path, readOnly, merge, missing, missing, missing, missing, missing, missing, missing, missing, pool, missing, missing, ignoreReadOnlyRecommended, missing, missing);

    I would suggest you can use the entire file path like the code above to test if it works in your environment.

    Thanks

    Best Regards


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.


    Thursday, December 24, 2015 6:36 AM
  • Yes I tried it exactly same way. It is removing the http: part and .mpp part. 
    Monday, December 28, 2015 9:34 AM
  • Hi Malin,

    How about using the complete file path in SharePoint library ? Did it work ?

    Thanks

    Best Regards


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Tuesday, December 29, 2015 1:24 AM
  • Hi Jerry, 

    No. Ultimately I downloaded the file to the local disk with a unique file name and read the values from that.

    This can be one of my environment issues as well. Though it is a fresh farm installation, I have installed Visual Studio 2015 there. I have seen many places where VS 2015 assemblies troubling SharePoint 2013. 

    Tuesday, December 29, 2015 3:25 AM
  • Hi Malin,

    As an alternative, I would suggest you can download the file from library firstly, then read it from local drive.

    More information:

    Download Files From SharePoint Library To Local File System

    Thanks

    Best Regards


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Tuesday, December 29, 2015 8:30 AM