Need a special offer?Find out if your project fits.
+

How to manage long paths in ASP.NET with Flexmonster Compressor?

Answered
Martin Torres asked on January 13, 2020

Hello,
I'm currently using version 2.7.4 of the compressor in ASP.NET with latest version of Flexmonster. When I try to read the Stream, it throws a "Path too long error". The maximum path length supported by Stream (System.IO.Stream) is 260 characters, and I have to make it work with 350+.
Is there any workaround to manage those path lengths? What I'm doing now is downloading the file to another folder of the server, converting it to string, to then read it with "CompressString" instead of' "CompressFile", but I would like to know if there's a better solution to it.
Thanks in advance
Best regards

1 answer

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster January 15, 2020

Hello, Martin,
 
Thank you for reaching out to us.
 
Our team would like to kindly suggest you consider the following: starting with version 4.6.2 of .NET Framework, long paths are supported by default. The runtime throws a PathTooLongException under the following conditions:

  • The operating system returns COR_E_PATHTOOLONG or its equivalent.
  • The length of the path exceeds Int16.MaxValue (32,767) characters.

 
In case update to the version 4.6.2+ is undesirable, apps that target the .NET Framework 4.6.1 and earlier but run under the .NET Framework 4.6.2 can enable Flong path support by including the following setting in the <runtime> element of the application configuration file:

<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false" />
</runtime>

 
More information about the exception and ways to handle it can be found following the link.
 
Otherwise, our team confirms that the way to transmit the data you have described is the only possible approach in order to avoid the exception.
 
We hope it works for you.
 
Best regards,
Illia

Please login or Register to Submit Answer