1

I am working on a file parser which parses ASCII text files generated from unix/linux in form of a bundle.

Upon searching, I came across PathTooLongException C# 4.5 in which AlphaFS is recommended.

I am using AlphaFS and the basic copy, paste, move functions work fine.

As this utility mimics System.IO, I referenced.

Alphaleonis.Win32.Filesystem;

However, FileStream fs = File.OpenRead(archiveFilenameIn); <-- FileStream asks me to reference System.IO.

In my program, I am using FileStream, Stream, FileAttributes, FileMode, FileAccess functions.

How can I implement the same using AlphaFS? Please do let me know if there is a better way to handle files with long paths.

UPDATE: I am using SharpZipLib to extract the contents of the bundle. The bundle could be in form of .tar or .tgz

The error occurs while extraction.

TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream);
tarArchive.ExtractContents(destFolder); <-- This line throws the error.
tarArchive.Close();

Upon looking into the definition, there is a reference of System.IO in TarArchive class of SharpZipLib.Tar

Tango
  • 386
  • 1
  • 6
  • 29
  • Can't you upgrade to 4.6.2 and enable long path support: https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/ – rene Sep 30 '17 at 11:49
  • @rene Unfortunately, No. Have to stick to .NET 4.5 and Windows 7 / Windows Server 2012 – Tango Sep 30 '17 at 11:51
  • do something like this `using FileStream = System.IO.FileStream;` so you can reference System.IO without cluttering/clashing of the types/namespaces. Example is from https://github.com/alphaleonis/AlphaFS/blob/develop/AlphaFS/Filesystem/File%20Class/File.OpenRead.cs#L24 – rene Sep 30 '17 at 11:54
  • @rene Gives me the error while I try to extract a file from the bundle. {"The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters."} – Tango Sep 30 '17 at 12:09
  • What is the exact stack trace then? Is that error coming from within SharpZipLib? – rene Sep 30 '17 at 12:17
  • @rene Yes, tarArchive.ExtractContents() is throwing the error. While looking at the definition of it, System.IO is referenced. Could this be the issue ? – Tango Sep 30 '17 at 12:30
  • If sharplib is not compatible with the longpath you're out of luck. – rene Sep 30 '17 at 12:54

0 Answers0