这个目录不一定存在,但是不能包含非法字符。

解决方案 »

  1.   

    文件名不能包含以下字符\/:*?"<>|
      

  2.   

    没有函数吗?不会让我自己去一个个看吧?GetFileAttributes 怎么用是判断目录名合法性啊?
      

  3.   

    用createfile 就可以了,他是支持目录的
    The CreateFile function creates or opens the following objects and returns a handle that can be used to access the object: 
    files 
    pipes 
    mailslots 
    communications resources 
    disk devices (Windows NT only)
    consoles 
    directories (open only)
    DirectoriesAn application cannot create a directory with CreateFile; it must call CreateDirectory or CreateDirectoryEx to create a directory.
      

  4.   

    MAX_PATH   256
    不可以包括 \/:*?"<>|
      

  5.   

    判断是否包括\/:*?"<>|等这些字符和判断他的长度是不够的,你可以试着建立一个叫"COM1"或是"nul"...的目录,虽然没包括以上那些非法字符,但也是不行的。我暂时也没有找到直接检查的函数,笨方法是创建一个目录,如果成功就说明他是合法的,如果不成功就非法。关注其它直接检查的方法!