delete a folder
-
Hello, I'm trying to delete a folder with all subfolder that are in it. I found this structure on MSN
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;try it like this
SHFILEOPSTRUCT op;
op.pFrom = _T("C:\\zipTest\\td10Updater\\*.*\0\0");
//op.pTo = _T(""); //will be ignored
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT;
SHFileOperation(&op);what is wrong ?
-
Hello, I'm trying to delete a folder with all subfolder that are in it. I found this structure on MSN
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;try it like this
SHFILEOPSTRUCT op;
op.pFrom = _T("C:\\zipTest\\td10Updater\\*.*\0\0");
//op.pTo = _T(""); //will be ignored
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT;
SHFileOperation(&op);what is wrong ?
I think you can use code in this way. CString szFilePath = "D:\\DEVAPP\\TestApp\\Debug\\delete"; char aChars[MAX_PATH]; memset(aChars, '\0', MAX_PATH); strcpy(aChars, szFilePath.GetBuffer(1)); SHFILEOPSTRUCT op; op.hwnd = AfxGetApp()->GetMainWnd()->m_hWnd; op.pFrom = aChars; op.pTo = ""; op.wFunc = FO_DELETE; op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI;; SHFileOperation(&op); :)
Sudhir Kumar
-
Hello, I'm trying to delete a folder with all subfolder that are in it. I found this structure on MSN
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;try it like this
SHFILEOPSTRUCT op;
op.pFrom = _T("C:\\zipTest\\td10Updater\\*.*\0\0");
//op.pTo = _T(""); //will be ignored
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT;
SHFileOperation(&op);what is wrong ?
I found what was my problem prior to deletion I browse the folder with a recursive function. Then when I try to delete the subdirectory cannot be deleted, they are in use... I cannot understand why. For browsing I used
WIN32_FIND_DATA FindFileData;
HANDLE hFindand while condition
while(FindNextFile(hFind, &FindFileData)!=0)
-
I found what was my problem prior to deletion I browse the folder with a recursive function. Then when I try to delete the subdirectory cannot be deleted, they are in use... I cannot understand why. For browsing I used
WIN32_FIND_DATA FindFileData;
HANDLE hFindand while condition
while(FindNextFile(hFind, &FindFileData)!=0)
If you want to delete the folder with all sub folders then there is no need of recursive function. :)
Sudhir Kumar
-
If you want to delete the folder with all sub folders then there is no need of recursive function. :)
Sudhir Kumar
I have a folder , I must browse this folder in order to make a 1:1 copy on a ftp server. Then I must delete this folder. For the browsing I use a recursive function. Now for some reason the subdirectory are still in use after the function ends and I cannot delete them....
-
I found what was my problem prior to deletion I browse the folder with a recursive function. Then when I try to delete the subdirectory cannot be deleted, they are in use... I cannot understand why. For browsing I used
WIN32_FIND_DATA FindFileData;
HANDLE hFindand while condition
while(FindNextFile(hFind, &FindFileData)!=0)
Perhaps you missed this from MSDN:
When the search handle is not needed,
close it by using the FindClose function.Since you haven't closed the handle, it's still in use. Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
Hello, I'm trying to delete a folder with all subfolder that are in it. I found this structure on MSN
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;try it like this
SHFILEOPSTRUCT op;
op.pFrom = _T("C:\\zipTest\\td10Updater\\*.*\0\0");
//op.pTo = _T(""); //will be ignored
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT;
SHFileOperation(&op);what is wrong ?
mihai123 wrote:
SHFileOperation
I always use this tested class :- http://www.codeproject.com/KB/shell/cshellfileop.aspx[^] when ever i want to do folder operations!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>
-
Hello, I'm trying to delete a folder with all subfolder that are in it. I found this structure on MSN
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;try it like this
SHFILEOPSTRUCT op;
op.pFrom = _T("C:\\zipTest\\td10Updater\\*.*\0\0");
//op.pTo = _T(""); //will be ignored
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT;
SHFileOperation(&op);what is wrong ?
You can use of _rmdir.