0

I have been following this answer in trying to read text from an XPS document.

I have the following code:

        string filePath = @"C:\A.xps";
        XpsDocument _xpsDocument = new XpsDocument(filePath, System.IO.FileAccess.Read);
        IXpsFixedDocumentSequenceReader fixedDocSeqReader = _xpsDocument.FixedDocumentSequenceReader;

The problem is fixedDocSeqReader is null.

I tried using this instead:

        var seq = _xpsDocument.GetFixedDocumentSequence();

But seq is also null.

Any ideas?

Community
  • 1
  • 1
Felix
  • 3,783
  • 5
  • 34
  • 53
  • Is this being called from partially trusted code? – Peter Ritchie Mar 09 '14 at 20:40
  • The root directory is protected in newer versions of Windows by design. Does the code work if you create the file in a subfolder, such as your documents folder? – Craig Lebakken Mar 10 '14 at 16:52
  • @PeterRitchie, I'm not sure. I've got about 15 lines of code in a main method. How do I check whether my code is partially trusted? – Felix Mar 10 '14 at 21:07
  • @CraigLebakken, I just tried placing the file in my documents folder, but `fixedDocSeqReader` is still null. – Felix Mar 10 '14 at 21:09

0 Answers0