checking if a folder exists or not
-
want to check if a folder exists in a computer or not. for example if the path is "c:\DK\Index " i want to check if the folders DK and Index already exists in c drive. if it doesn't exist,then these folders should be created. if the folders already exists nothing needs to be done. i want to check this when the dialog box is initialised. can anyone give the code to do this. Thank You
-
want to check if a folder exists in a computer or not. for example if the path is "c:\DK\Index " i want to check if the folders DK and Index already exists in c drive. if it doesn't exist,then these folders should be created. if the folders already exists nothing needs to be done. i want to check this when the dialog box is initialised. can anyone give the code to do this. Thank You
see _access Cleek | Image Toolkits | Thumbnail maker
-
want to check if a folder exists in a computer or not. for example if the path is "c:\DK\Index " i want to check if the folders DK and Index already exists in c drive. if it doesn't exist,then these folders should be created. if the folders already exists nothing needs to be done. i want to check this when the dialog box is initialised. can anyone give the code to do this. Thank You
Hi , Try this :
CFileFind finder; CString szPath , szCMD; szPath = "c:\\DK\\Index"; // create the directory - if there isn't one allready if(!finder.FindFile(szPath)) { szCMD = "mkdir "; szCMD += szPath; system((LPCTSTR)szCMD); }
With best regards, Eli
-
want to check if a folder exists in a computer or not. for example if the path is "c:\DK\Index " i want to check if the folders DK and Index already exists in c drive. if it doesn't exist,then these folders should be created. if the folders already exists nothing needs to be done. i want to check this when the dialog box is initialised. can anyone give the code to do this. Thank You
WIN32_FIND_DATA m_data; HANDLE hFile; hFile=FindFirstFile("c:\\test",&m_data); if(hFile==INVALID_HANDLE_VALUE) MessageBox("Not Found"); else { MessageBox("ok"); FindClose(hFile); }
_**
**_
whitesky
-
want to check if a folder exists in a computer or not. for example if the path is "c:\DK\Index " i want to check if the folders DK and Index already exists in c drive. if it doesn't exist,then these folders should be created. if the folders already exists nothing needs to be done. i want to check this when the dialog box is initialised. can anyone give the code to do this. Thank You
Another way to do it: Using CFileStatus from MFC..
CString folderPath = \_T("C:\\\\DK\\\\Index"); CFileStatus status; if(!CFile::GetStatus( folderPath, status ) ) // static function { AfxMessageBox(\_T("Directory does not exist.(\\"") + folderPath + \_T("\\")\\n"), MB\_OK|MB\_ICONINFORMATION); ... }
The use of
_access
(posted by Chris Losinger) may be more suitable for your needs.-- **Ricky Marek** (_AKA: rbid_)
-- "Things are only impossible until they are not" --- Jean-Luc Picard My articles -
Hi , Try this :
CFileFind finder; CString szPath , szCMD; szPath = "c:\\DK\\Index"; // create the directory - if there isn't one allready if(!finder.FindFile(szPath)) { szCMD = "mkdir "; szCMD += szPath; system((LPCTSTR)szCMD); }
With best regards, Eli
-
want to check if a folder exists in a computer or not. for example if the path is "c:\DK\Index " i want to check if the folders DK and Index already exists in c drive. if it doesn't exist,then these folders should be created. if the folders already exists nothing needs to be done. i want to check this when the dialog box is initialised. can anyone give the code to do this. Thank You
Hi !!! If you want xou can use the InetSTL from STLSoft library. There is a function that can check wheather the directory exists or not. You can find it here: http://www.stlsoft.org I hope, I helped you. By. -:KNOX:-