Long FIle Path

Is there any way to use the mailmessage save to use a long path name such as //?/c:xxxxxxx

thanks

Hi Jon,

I have tested this at my end and the API respects the maximum path length defined by Microsoft i.e. 256 characters. In your earlier post (before editing), I created a complete path as your mentioned and saved a message at that path successfully without having any long path exception. Please share more details with us for further assistance in this regard.

The problem was resolved after restarting the IDE. That is why I closed the original issue. However we have found that the mailmessage.save raises an invalid path characters when trying to use the long path prefix \?.





From Microsoft:





To specify an extended-length path, use the “\?” prefix. For example, “\?\D:\very long path”.





The maximum path of 32,767 characters is approximate, because the “\?” prefix may be expanded to a longer string by the system at run time, and this expansion applies to the total length.





The “\?” prefix can also be used with paths constructed according to the universal naming convention (UNC). To specify such a path using UNC, use the “\?\UNC” prefix.

Hi Jon,

Please allow us some time so that we can feedback about such possibility from our Product team. We shall write back here as soon as some feedback is available in this regard.

Hi Jon,

Could you try this with .NET framework without using the Aspose.Email API? We get exception even while using the .NET File API as shown in the following sample code.

Sample Code:

File.Create(@"\?\C:\Spring2015\6Apr15-152925\Top of Personal Folders\Inbox\Litigation’s Support Stuf f[litigation_support@yahoogroups.com] 2 Day EDD Lifecycle class comes to Philadelphia(1).m");

That fails with a System.ArgumentException Illegal characters in path.

I take it that the source code is C#. Support of long path in C# can be achieved using Microsoft.experimental.io 2.

Microsoft.Experimental.IO 1.0.0

This library provides functionality to make it easier to work with paths that are longer than the current 259 character limit.

Hi Jon,

Yes, the source code is that of C#. Well in case of Microsoft.Experimental.IO, you can use the FileStream to write the message to such a long long path as shown in the following code sample.

Code:

using (FileStream stream = LongPathFile.Open(@"C:\Spring2015\6Apr15-152925\Top of Personal Folders\Inbox\Litigation’s Support Stuf f\here is another folder working onwards to the issue reproducing\this is a test folder for working with the new thinking\another new folder for working with the l[litigation_support@yahoogroups.com] 2 Day EDD Lifecycle class comes to Philadelphia(1).msg", FileMode.Create, FileAccess.Write))
{
    MailMessage msg = new MailMessage();
    msg.Save(stream, Aspose.Email.Mail.SaveOptions.DefaultMsgUnicode);
}

Thank you for pointing this out. I have made the changes and will run more tests today but this looks it works.