.NET open xps file from Sharepoint location using XpsDocument class

28 Views Asked by At

I have difficulties with accessing a .xps file from Sharepoint. I set a string variable with the path and use it like this:

string xpsFilePath = @"https://test.sharepoint.com/sites/PPS/Eng/PPSKBWiki/Shared%20Documents/test_v1.0.xps";
XpsDocument xpsDocument = new(xpsFilePath, System.IO.FileAccess.Read);

This results in an error

System.IO.IOException: The syntax for the file name, directory name or volume label is incorrect.

If I use the following path instead it works flawlessly:

string xpsFilePath = @"C:\Users\tastatur\OneDrive\Berechnungen\Schraubenberechnung\beta\test_v1.0.xps"

I use the same Sharepoint directory as in the first example to open Excel files (using the Office.Interop.Excel COM package), so it's not a general access problem.

Is there something else I need to implement or do I have to store the file first?

Best regards and thank you.

I tried using the same method as opening the file from a local path.

XpsDocument xpsDocument = new(filePath, System.IO.FileAccess.Read);

or

XpsDocument xpsDocument = new(package, CompressionOption.Maximum,filePath);

Both throws the System.IO.IOException

0

There are 0 best solutions below