Home > Back-end >  The great god for help the new want to delete the selected file within the folder debugging when sol
The great god for help the new want to delete the selected file within the folder debugging when sol

Time:10-11

 

Void myDeleteDirectory (cstrings directory_path)
{
CFileFind finder.
Cstrings path;
Path=directory_path;
BOOL bWorking=finder. FindFile (path);
While (bWorking) {
BWorking=finder. The FindNextFile ();
If (finder. IsDirectory () & amp; & ! Finder. IsDots ()) {
//processing folder
MyDeleteDirectory (finder. GetFilePath ());//recursive delete folder
RemoveDirectory (finder. GetFilePath ());
}
The else DeleteFile (finder. GetFilePath ());
}


}
Cstrings sFolderPath;

Void CDeleteDlg: : OnBnClickedButton1 ()
{
//TODO: add the control notification handler code

BROWSEINFO bi;
TCHAR Buffer [MAX_PATH];
//initialization parameter entrance bi start
Bi. HwndOwner=NULL;
Bi. PidlRoot=NULL;//root directory
Bi. PszDisplayName=Buffer;
Bi. LpszTitle=_T (" select the folder path ");

Bi. UlFlags=BIF_EDITBOX;//including file
Bi. LPFN=NULL;
Bi. IImage=IDR_MAINFRAME;
//initialization parameter bi entrance end
//display dialog
LPITEMIDLIST pIDList=SHBrowseForFolder (& amp; Bi);
If (pIDList) {
SHGetPathFromIDList (pIDList, Buffer);
//folder path to Buffer the
SFolderPath=Buffer;
//set the path to the edit box the text of
M_editDir. SetWindowText (sFolderPath);
}
LPMALLOC LPMALLOC;
If (FAILED (SHGetMalloc (& amp; LpMalloc))) return;
//release the memory
LpMalloc - & gt; Free (pIDList);
LpMalloc - & gt; Release ();
}


Void CDeleteDlg: : OnEnChangeEdit1 ()
{
//TODO: if the control is RICHEDIT control, it will not be
//send the notice, unless the rewrite CDialogEx: : OnInitDialog ()
//function and call the CRichEditCtrl (.) SetEventMask (),
//at the same time the ENM_CHANGE flag "or" operation to the mask,

//TODO: add the control notification handler code
}


Void CDeleteDlg: : OnBnClickedButton2 ()
{
//TODO: add the control notification handler code
MyDeleteDirectory (sFolderPath);
RemoveDirectory (sFolderPath);
}
  • Related