How can I use FileInfo class, avoiding PathTooLongException?

后端 未结 4 1368
遇见更好的自我
遇见更好的自我 2020-12-03 14:17

How can I use (to avoid PathTooLongException):

System.IO.FileInfo

with paths bigger than 260 chars?

Are there similar classes/metho

4条回答
  •  自闭症患者
    2020-12-03 15:20

    Here at work we deal with long paths quite frequently, and we therefore had to basically roll our own System.IO to do it. Well not really, but we rewrote File, Directory, FileInfo, DirectoryInfo and Path just to name a few. The basic premise is that it's all possible from a Win32 API perspective, so all you really need to do at the end of the day is invoke the Unicode versions of the Win32 API functions, and then you're good. It's alot of work, and can be a pain in the ass at times, but there's really no better way to do it.

提交回复
热议问题