Check if file existe, get temporary file name?
-
How to check if file existe (not by trying to open it, fail : not existe or not) How to get the temporary file name which is not coincide with existing files.
Hi, 1. Check File exists CFileFind chkFileExistence; if(chkFileExistence.FindFile(strFileName)) { //File exists }else{ //File does not exists } 2. Creating Temporary File Name You can use different methods to create a temporary file name. My suggestion, try to create a file name with Date & Time. Hope this helps. regards ~Hari~
-
Hi, 1. Check File exists CFileFind chkFileExistence; if(chkFileExistence.FindFile(strFileName)) { //File exists }else{ //File does not exists } 2. Creating Temporary File Name You can use different methods to create a temporary file name. My suggestion, try to create a file name with Date & Time. Hope this helps. regards ~Hari~
-
How to check if file existe (not by trying to open it, fail : not existe or not) How to get the temporary file name which is not coincide with existing files.
to check if a file exist you can use the shell function
BOOL PathFileExists( LPCTSTR pszPath );
it takes the file path and return 1 if it exist and 0 if not for temporary files, there is the function
UINT GetTempFileName( LPCTSTR lpPathName, // directory name LPCTSTR lpPrefixString, // file name prefix, first three letters is taken only UINT uUnique, // integer LPTSTR lpTempFileName // file name buffer );
which can be used to generate temporary file names. The temporary path is formed like this
lpPathName+'\'+lpPrefixString+[uUnique as hexadecimal] + ".tmp"
and returned in thelpTempFileName
for e.g if the path isc:\
and the unique integer is10
and the prefix is"fil"
the result will bec:\fil000A.tmp
. TheuUnique
parameter should have a unique integer value but if you passed 0 the system will assign this unique value. -
to check if a file exist you can use the shell function
BOOL PathFileExists( LPCTSTR pszPath );
it takes the file path and return 1 if it exist and 0 if not for temporary files, there is the function
UINT GetTempFileName( LPCTSTR lpPathName, // directory name LPCTSTR lpPrefixString, // file name prefix, first three letters is taken only UINT uUnique, // integer LPTSTR lpTempFileName // file name buffer );
which can be used to generate temporary file names. The temporary path is formed like this
lpPathName+'\'+lpPrefixString+[uUnique as hexadecimal] + ".tmp"
and returned in thelpTempFileName
for e.g if the path isc:\
and the unique integer is10
and the prefix is"fil"
the result will bec:\fil000A.tmp
. TheuUnique
parameter should have a unique integer value but if you passed 0 the system will assign this unique value. -
How to check if file existe (not by trying to open it, fail : not existe or not) How to get the temporary file name which is not coincide with existing files.
TPN wrote: How to check if file existe (not by trying to open it, fail : not existe or not) You can use _access() or CFile::GetStatus(). TPN wrote: How to get the temporary file name which is not coincide with existing files. Use GetTempFileName().
-
How to check if file existe (not by trying to open it, fail : not existe or not) How to get the temporary file name which is not coincide with existing files.