Reputation: 60213
My open source software synchronizes a remote folder to the local desktop. The remote folder can be on Alfresco, where path length has no limit (/root/very/very/very/long/name.txt
).
When developing the application I used System.IO.File.OpenWrite
and System.IO.Stream.Write
, but it appears that they don't support paths over a few hundred characters, so users report errors like PathTooLongException
when working with long paths.
UNC paths must absolutely be avoided, because they lead to incompatibility with some applications.
What library/code should be used in this case?
It must be open source C#.
Upvotes: 4
Views: 3889
Reputation: 60213
AlphaFS lets you use very long paths (using the "\?\" style) and mimics the System.IO namespace.
You will probably be able to use this library just as if you were using System.IO. For example, AlphaFS.Win32.Filesystem.File.Copy() instead System.IO.File.Copy().
(source)
Upvotes: 3
Reputation: 45101
You can try the Base Class Libraries Long Path implementation. But be aware that not everything will work if you start to mix up with default .NET I/O methods.
Upvotes: 2
Reputation: 60213
Since the revision 185 (February 19th, 2013), the library is covered by Microsoft Public License (MS-PL), as specified in the headers of the source code files.
Looks promising, but author advises against using it in an enterprise environment, since the code is not solid enough.
This library has some unit tests, but lacks documentation.
Upvotes: 1
Reputation: 738
You could try splitting the path up by using relative paths as outlined in this answer using:
Directory.SetCurrentDirectory()
PathTooLongException in C# code
Upvotes: 1
Reputation: 60213
".NET 2.0 Workaround for PathTooLongException" (article+code).
Licensed under The Code Project Open License (CPOL), which is not open source apparently.
Only 2 commits do not make for a very active project, though...
Upvotes: 1