I want to create a file use a random name to prevent the same name risk,
but in SDK and MFC, I can't not find a mathod or a function to prevent the risk. If u know ,Please tell me, thx.

解决方案 »

  1.   

    Use API FindFirstFile to find the file is exist or not!!
    HANDLE FindFirstFile(
      LPCTSTR lpFileName,  // pointer to name of file to search for
      LPWIN32_FIND_DATA lpFindFileData 
                           // pointer to returned information
    );
      

  2.   

    I think you should first to check if the file  has the same name with your disk files.before you create the new file,should change over other file name.
      

  3.   

    use _open() function to open file. if the file does not exist, the return value should be -1.
      

  4.   

    use _open() function to open file. if the file does not exist, the return value should be -1.