Loading ...

Path too long error message when exceeding MAX_PATH | CodeAsp.Net

Path too long error message when exceeding MAX_PATH

 /5
0 (0votes)

While using Directory.GetFiles I started getting the following excpetion 

Path too long error message when exceeding MAX_PATH

Luckily I came across the following library: Delimon.Win32.I​O Library (V4.0) http://gallery.technet.microsoft.com/DelimonWin32IO-Library-V40-7ff6b16c This Library is written specifically to overcome the limitation of the .NET Framework to use long Path & File Names. This is how you can use it:

using Delimon.Win32.IO; 
 
namespace ConsoleApplication1 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            string[] files = Directory.GetFiles(@"c:\temp"); 
            foreach (string file in files) 
            { 
                Console.WriteLine(file); 
            } 
            Console.ReadLine(); 
        } 
    } 
}

You need to extract the Delimon.Win32.IO.dll from their install and add reference to your solution so as to make Delimon.Win32.IO namespace availaible to your solution.

Comments (no comments yet)

Top Posts