Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CString.Format anomaly Pin
jeron117-Jun-15 8:19
jeron117-Jun-15 8:19 
QuestionMultithread c Windows Pin
mosine16-Jun-15 2:22
mosine16-Jun-15 2:22 
AnswerRe: Multithread c Windows Pin
Jochen Arndt16-Jun-15 2:33
professionalJochen Arndt16-Jun-15 2:33 
GeneralRe: Multithread c Windows Pin
mosine16-Jun-15 2:47
mosine16-Jun-15 2:47 
GeneralRe: Multithread c Windows Pin
mosine16-Jun-15 3:01
mosine16-Jun-15 3:01 
GeneralRe: Multithread c Windows Pin
Jochen Arndt16-Jun-15 3:02
professionalJochen Arndt16-Jun-15 3:02 
GeneralRe: Multithread c Windows Pin
mosine16-Jun-15 3:21
mosine16-Jun-15 3:21 
QuestionFailure to remove folders after using CFileDialog DoModal Pin
Still learning how to code15-Jun-15 21:28
Still learning how to code15-Jun-15 21:28 
I picked up a function RecursiveDelete on the internet, as I needed to erase all files and folders on an SD card (as part of a larger project). I was having problems insofar as the function would fail on removing the folders after CFileDialog DoModal - there were two nested folders, the deepest failing with code 32 ("in use by another proicess") and the shallowest with 145 ("folder not empty" - expected !)
However, if I call the function BEFORE the DoModal, then everything works fine.
I have extracted the relevent code into a simpler project and it still fails
Perhaps some kind soul can throw some light on why this is so !!

C++
CFileDialog dlgFileBrowse(true);

	UINT uiFileBrowseDlgRC;

// OK here 
	RecursiveDelete("F:");		// 20150615  

//
	uiFileBrowseDlgRC = dlgFileBrowse.DoModal();

//   FAILS HERE - YES


void CDeleteFolderTestDlg::RecursiveDelete(CString szPath)
{
	CFileFind ff;
	BOOL bResult;
	CString path = szPath;
	
	if(path.Right(1) != '\\')	
		path += '\\';			

	path += "*.*";

	bResult = ff.FindFile(path);
	BOOL bItemDelete;
	DWORD dwLastError;
	CString szFilePath;

	while(bResult)
	{
		bResult = ff.FindNextFile();
		if (!ff.IsDots() && !ff.IsDirectory())
		{
			szFilePath = ff.GetFilePath();
			bItemDelete = DeleteFile(szFilePath);
			if(!bItemDelete)
				dwLastError = GetLastError();
		}
		else if (ff.IsDirectory() && !ff.IsDots())	
		{
			path = ff.GetFilePath();

			RecursiveDelete(path);

			bItemDelete = RemoveDirectory(path);
			if(!bItemDelete)
				dwLastError = GetLastError();
		}
	}
}

//	RecursiveDelete("F:");

Doug


modified 16-Jun-15 3:39am.

AnswerRe: Failure to remove folders after using CFileDialog DoModal Pin
Freak3016-Jun-15 0:21
Freak3016-Jun-15 0:21 
GeneralRe: Failure to remove folders after using CFileDialog DoModal Pin
Jochen Arndt16-Jun-15 0:24
professionalJochen Arndt16-Jun-15 0:24 
GeneralRe: Failure to remove folders after using CFileDialog DoModal Pin
Still learning how to code16-Jun-15 2:08
Still learning how to code16-Jun-15 2:08 
AnswerRe: Failure to remove folders after using CFileDialog DoModal Pin
Jochen Arndt16-Jun-15 0:22
professionalJochen Arndt16-Jun-15 0:22 
GeneralRe: Failure to remove folders after using CFileDialog DoModal Pin
Still learning how to code16-Jun-15 2:12
Still learning how to code16-Jun-15 2:12 
GeneralRe: Failure to remove folders after using CFileDialog DoModal Pin
Jochen Arndt16-Jun-15 2:24
professionalJochen Arndt16-Jun-15 2:24 
GeneralRe: Failure to remove folders after using CFileDialog DoModal - **** FIXED (I think !) **** Pin
Still learning how to code16-Jun-15 2:54
Still learning how to code16-Jun-15 2:54 
GeneralRe: Failure to remove folders after using CFileDialog DoModal - **** FIXED (I think !) **** Pin
Jochen Arndt16-Jun-15 3:19
professionalJochen Arndt16-Jun-15 3:19 
QuestionRe: Failure to remove folders after using CFileDialog DoModal Pin
David Crow16-Jun-15 4:21
David Crow16-Jun-15 4:21 
QuestionExisting VR Frame Renderers Pin
Trevor Johansen15-Jun-15 15:25
Trevor Johansen15-Jun-15 15:25 
QuestionLoad CSV file to a database in Windows 64bit Pin
aks.14-Jun-15 22:36
aks.14-Jun-15 22:36 
AnswerRe: Load CSV file to a database in Windows 64bit Pin
Jochen Arndt14-Jun-15 23:45
professionalJochen Arndt14-Jun-15 23:45 
QuestionNew to C++ and Programming, Absolutely new Pin
Member 1176562614-Jun-15 18:36
Member 1176562614-Jun-15 18:36 
AnswerRe: New to C++ and Programming, Absolutely new Pin
Amarnath S14-Jun-15 19:00
professionalAmarnath S14-Jun-15 19:00 
GeneralRe: New to C++ and Programming, Absolutely new Pin
Member 1176562614-Jun-15 19:26
Member 1176562614-Jun-15 19:26 
GeneralRe: New to C++ and Programming, Absolutely new Pin
Richard MacCutchan14-Jun-15 21:42
mveRichard MacCutchan14-Jun-15 21:42 
QuestionAfxGetApp anomaly Pin
ForNow10-Jun-15 9:18
ForNow10-Jun-15 9:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.