C# 长度超过248字符的路径或文件的查找

  昨天帮同事写了一个查找文件的小工具,却发现弹出了这个错误信息: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. 大概的意思就是:指定的路径或文件名太长,或者两者都太长。完全限定文件名必须少于 260 个字符,并且目录名必须少于 248 个字符。用.NET的类库或API的findfirst\findnext都解决不了这个问题.

  在MSDN上关于路径和文件的命名规则, 长度和\\?\前缀的文档:
http://msdn2.microsoft.com/en-us/library/aa365247.aspx

  于是用API的findfirstfile/findnextfile重写了那个索引的函数(下载请点此处

 

Code

 

 

  

posted @ 2009-06-24 09:42  novel  阅读(2616)  评论(0编辑  收藏  举报