Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DirectoryInfo, FileInfo and very long path

I try to work with DirectoryInfo, FileInfo with very long path.

  • I try use \\?\c:\long path (i got illegal caracter with fileInfo and DirectoryInfo)
  • I try use file://c:/long path (i got uri not supported)

Can i use ~ in a path or something else.

I read this post but i would like to use another way that call a API. Is it any other solutions ?

There is an article from microsoft for use \\? in file path link text

The question is how can i work with very long path, and DirectoryInfo, and FileInfo for path who are more longer that 256 char

like image 507
Cédric Boivin Avatar asked Sep 08 '09 13:09

Cédric Boivin


3 Answers

The Library is available again on this location.

This is a .NET Library written against .NET Framework 2.0 and can be used to access very long folder and files from a .NET application.

Since the .NET Framework does not support long filenames :-( I had to write a library that calls the WIN32 API and wraps those functions like System.IO. While it is not a complete replica of the System.IO it does have most objects and functions available.

Delimon.Win32.IO replaces basic file functions of System.IO with long path names support for characters up to 32,767 Characters So bye bye MAX_PATH problem

Did you ever run into this problem?

System.IO.PathTooLongExceptionwas unhandled.

Message:

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.

like image 116
jdelimon Avatar answered Oct 19 '22 17:10

jdelimon


Looking at the Long Paths in .NET blog post series, it looks like going to the Win32 API through P/Invoke is the only solution at the moment, other than restructuring your directories so that you don't hit the limit.

like image 10
bdukes Avatar answered Oct 19 '22 17:10

bdukes


The Delimon.Win32.I​O Library (V4.0) is also available, it is written against .NET Framework 4.0 and can be used either on x86 & x64 systems.

like image 6
TripleAntigen Avatar answered Oct 19 '22 16:10

TripleAntigen