PathTooLongException in C# code

前端 未结 4 1700
攒了一身酷
攒了一身酷 2020-12-07 04:38

i have the following code:

 public static void Serialize()
    {

        List dirs = FileHelper.GetFilesRecursive(fileDirectoryPath);
                 


        
4条回答
  •  [愿得一人]
    2020-12-07 04:56

    Something like the .LastAccessTime property of Delimon.Win32.IO.FileInfo, might do the trick.

    Delimon is a library on Microsoft TechNet for overcoming the long filenames problem, it's called Delimon.Win32.I​O Library (V4.0) and it has its own versions of key classes from System.IO

    For example, you would replace:

    System.IO.Directory.GetFiles 
    

    with

    Delimon.Win32.IO.Directory.GetFiles
    

    which will let you handle long files and folders.

    From the website:

    Delimon.Win32.IO replaces basic file functions of System.IO and supports File & Folder names up to up to 32,767 Characters.

    This Library is written on .NET Framework 4.0 and can be used either on x86 & x64 systems. The File & Folder limitations of the standard System.IO namespace can work with files that have 260 characters in a filename and 240 characters in a folder name (MAX_PATH is usually configured as 260 characters). Typically you run into the System.IO.PathTooLongException Error with the Standard .NET Library.

提交回复
热议问题