RemoveDirectoryW()
-
Hi, im using RemoveDirectoryW() ...the problem is.. RemoveDirectoryW(L"c:\\test\\testing"); the above deletes the folder testing but when.... the path to delete is present in two LPCWSTR"s then how can i add them ie... LPCWSTR lpPath1=L"c:\\temp\\folder1\\"; LPCWSTR lpPath2=L"testing\\tester"; i need to pass the combination of the above to RemoveDirectoryW()(finally i should delete tester).....Please let me know how can i do this....
-
Hi, im using RemoveDirectoryW() ...the problem is.. RemoveDirectoryW(L"c:\\test\\testing"); the above deletes the folder testing but when.... the path to delete is present in two LPCWSTR"s then how can i add them ie... LPCWSTR lpPath1=L"c:\\temp\\folder1\\"; LPCWSTR lpPath2=L"testing\\tester"; i need to pass the combination of the above to RemoveDirectoryW()(finally i should delete tester).....Please let me know how can i do this....
Not sure what you're trying to do. Do you want to delete a directory that has sub-directories? Could you re-phrase your request a bit?
-
Not sure what you're trying to do. Do you want to delete a directory that has sub-directories? Could you re-phrase your request a bit?
Yes i will ..... I need to delete a folder named "Test" which is present in the folder TEMP(Environment variable)... im able to get the path of TEMP using... WCHAR buffer[1042]={'\0'}; DWORD size=1042; ::GetEnvironmentVariableW(L"TEMP",(LPWSTR)buffer,size); CString csPath; csPath=buffer; im able to get the path of TEMP in csPath... now i have to delete the folder Test which is inside that TEMP folder.... When i use RemoveDirectoryW() i need to pass the path(in LPCWSTR) to Test folder....so please help me to attain this....
-
Hi, im using RemoveDirectoryW() ...the problem is.. RemoveDirectoryW(L"c:\\test\\testing"); the above deletes the folder testing but when.... the path to delete is present in two LPCWSTR"s then how can i add them ie... LPCWSTR lpPath1=L"c:\\temp\\folder1\\"; LPCWSTR lpPath2=L"testing\\tester"; i need to pass the combination of the above to RemoveDirectoryW()(finally i should delete tester).....Please let me know how can i do this....
To concatenate the two strings, you could use something like this:
LPCWSTR lpPath1=L"c:\\temp\\folder1\\";
LPCWSTR lpPath2=L"testing\\tester";std::basic_string<WCHAR> strPath = lpPath1;
strPath += lpPath2;RemoveDirectoryW(strPath.c_str());
This requires a
#include <string>
. Note that I'd recommend generic text mappings (with_T
, etc.) instead of just using Unicode directly.
Too many passwords to remember? Try KeePass Password Safe!
-
Yes i will ..... I need to delete a folder named "Test" which is present in the folder TEMP(Environment variable)... im able to get the path of TEMP using... WCHAR buffer[1042]={'\0'}; DWORD size=1042; ::GetEnvironmentVariableW(L"TEMP",(LPWSTR)buffer,size); CString csPath; csPath=buffer; im able to get the path of TEMP in csPath... now i have to delete the folder Test which is inside that TEMP folder.... When i use RemoveDirectoryW() i need to pass the path(in LPCWSTR) to Test folder....so please help me to attain this....
See Dominik's reply below. You also have to consider that RemoveDirectory will only delete empty directories. You might consider using SHFileOperation, here's an example: http://bobmoore.mvps.org/Win32/w32tip28.htm[^]
-
To concatenate the two strings, you could use something like this:
LPCWSTR lpPath1=L"c:\\temp\\folder1\\";
LPCWSTR lpPath2=L"testing\\tester";std::basic_string<WCHAR> strPath = lpPath1;
strPath += lpPath2;RemoveDirectoryW(strPath.c_str());
This requires a
#include <string>
. Note that I'd recommend generic text mappings (with_T
, etc.) instead of just using Unicode directly.
Too many passwords to remember? Try KeePass Password Safe!
-
CString strPath1 = _T("c:\\temp\\folder1\\");
CString strPath2 = _T("testing\\tester");CString strPath = strPath1 + strPath2;
RemoveDirectory(strPath);
Too many passwords to remember? Try KeePass Password Safe!
-
CString strPath1 = _T("c:\\temp\\folder1\\");
CString strPath2 = _T("testing\\tester");CString strPath = strPath1 + strPath2;
RemoveDirectory(strPath);
Too many passwords to remember? Try KeePass Password Safe!
-
Sorry i mean to say if only lpPath1 is Cstring and lpPath2 is LPCWSTR then how can i add them and pass to RemoveDirectoryW() Please let me know.....
If you're compiling in Unicode mode, it's basically just the same:
CString strPath1 = _T("c:\\temp\\folder1\\");
LPCWSTR lpPath2 = L"testing\\tester";CString strPath = strPath1 + lpPath2;
RemoveDirectoryW(strPath);
Too many passwords to remember? Try KeePass Password Safe!
-
If you're compiling in Unicode mode, it's basically just the same:
CString strPath1 = _T("c:\\temp\\folder1\\");
LPCWSTR lpPath2 = L"testing\\tester";CString strPath = strPath1 + lpPath2;
RemoveDirectoryW(strPath);
Too many passwords to remember? Try KeePass Password Safe!