Error: File Path is Too Long

后端 未结 4 1048
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 17:57

i am trying to use the various file functions in C# like File.GetLastWriteTime, copy command on the file placed at the path greater than maximum allowed path on

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-18 18:18

    try with this code

    var path = Path.Combine(@"\\?\", filesToBeCopied[j]); //don't forget extension
    

    "\?\" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system.

    Important : Not all file I/O APIs support "\?\", you should look at the reference topic for each API

提交回复
热议问题