Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Thu Mar 04, 2021 7:46 am

If the file path is longer than Windows default MAX_PATH, I will get the exception as below even though I put the extend prefix to my file path like this \\?\D:\.........

Code: Select all
java.lang.Exception: class com.spire.office.packages.sprlvD: The file name is too long. The fully qualified file name must be less than 260 characters and the directory name must be less than 248 characters
com.spire.doc.Document.spr  (Unknown Source)
com.spire.doc.Document.loadFromFile(Unknown Source)
com.spire.doc.Document.spr  (Unknown Source)
com.spire.doc.Document.loadFromFile(Unknown Source)
com.qnap.qsirch.spire.WordConverter.convert(WordConverter.java:17)
com.qnap.qsirch.spire.Executor.call(Executor.java:30)
com.qnap.qsirch.spire.Executor.call(Executor.java:7)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.lang.Thread.run(Thread.java:821)


Is there any way to solve this problem without adjust my PC setting?

I found I can create a symbolic link to long path file, and use the path of link as input string to feed LoadFromFile method, but it just works if there is no non-ascii character in the physical path of long path file.
If there is non-ascii character in the physical path, I will get exception like below.
Code: Select all
java.lang.Exception: "C:\Users\User\symlink-to-non-ascii-word.dot" is not exits.
        at com.spire.doc.Document.spr  (Unknown Source)       
        at com.spire.doc.Document.loadFromFile(Unknown Source)
        at com.qnap.qsirch.spire.WordConverter.convert(WordConverter.java:17)
        at com.qnap.qsirch.spire.Executor.call(Executor.java:30)
        at com.qnap.qsirch.spire.Executor.call(Executor.java:7)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.lang.Thread.run(Thread.java:821)
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0

peiyaochang
 
Posts: 2
Joined: Thu Mar 04, 2021 7:20 am

Thu Mar 04, 2021 10:21 am

Hello,

Thanks for your inquiry.

For the issue of the file name is too long: Sorry that our product does not support loading the file path which is longer than Windows default MAX_PATH. But I recommend that you could use doc.loadFromStream(stream, FileFormat.Docx); method to read your document data.

For the issue about non-ascii character in the physical path: I tested the following code with the latest Spire.Doc V4.3.2, but did not reproduce your issue.
Code: Select all
      String filePath = "F:\\aqwertyuiopa汉字sdfghjklzxcvbnm\\aqwertyuiopasdfghjklzxcvbnm\\aqwertyuiopasdfghjklzxcvbnm\\aqwertyuiopasdfghjklzxcvbnm\\aqwertyuiopasdfghjklzxcvbnm\\aqwertyuiopasdfghjklzxcvbnm\\aqwertyuiopasdfghjklzxcvbnm\\aqwertyuiopasdfghjklzxcvbnm\\aqwertyuiopasdfghjkl\\";
      String newpath = filePath + "aqwertyuiopasdfghjklzxcvbnm.docx" ;
      
       Path existingFilePath = Paths.get(newpath);
       Path symLinkPath = Paths.get("F:\\Users\\User\\symlink-to-non-ascii-word.dot");

       File file = symLinkPath.toFile();
       if(!file.exists()) {
          Files.createLink(symLinkPath, existingFilePath);
       }

      Document doc = new Document();
      doc.loadFromFile(symLinkPath.toString());
      System.out.println("open well");

To help us investigate your issue, please provide us with your input path and whole testing code for reference. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 390
Joined: Wed Nov 04, 2020 2:29 am

Fri Mar 05, 2021 1:43 am

Dear Marcia.Zhou

Thanks for your reply.

I tried another api loadFromStream, and it worked well. So I will use this api to solve my long path problem.

peiyaochang
 
Posts: 2
Joined: Thu Mar 04, 2021 7:20 am

Fri Mar 05, 2021 1:57 am

Hello,

Thanks for your feedback!

Glad to hear that your issue has been solved.

If you encounter any issues related to our product in the future, just feel free to contact us.

Have a nice day!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 390
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.Doc