Click here to Skip to main content
16,007,443 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CArchive problem - is there a genius who can help? Pin
Joaquín M López Muñoz3-Oct-01 9:54
Joaquín M López Muñoz3-Oct-01 9:54 
GeneralSorry, but no that won't work Pin
Joel Holdsworth3-Oct-01 10:03
Joel Holdsworth3-Oct-01 10:03 
GeneralRe: Sorry, but no that won't work Pin
Joaquín M López Muñoz3-Oct-01 10:39
Joaquín M López Muñoz3-Oct-01 10:39 
GeneralDeleting a file Pin
RobJones3-Oct-01 9:28
RobJones3-Oct-01 9:28 
GeneralRe: Deleting a file Pin
Joaquín M López Muñoz3-Oct-01 9:46
Joaquín M López Muñoz3-Oct-01 9:46 
GeneralRe: Deleting a file Pin
Joaquín M López Muñoz3-Oct-01 9:48
Joaquín M López Muñoz3-Oct-01 9:48 
GeneralRe: Deleting a file Pin
RobJones3-Oct-01 11:39
RobJones3-Oct-01 11:39 
GeneralRe: Deleting a file Pin
Joaquín M López Muñoz3-Oct-01 11:58
Joaquín M López Muñoz3-Oct-01 11:58 
Is this a good way of implementing what you have suggested?

No, it is not. DeleteFile() returns either TRUE or FALSE, and only in the latter case can you use GetLastError() to know the detailed cause of the failure:
BOOL bResult=DeleteFile("Source.txt");
if(!bResult){
  DWORD dw=GetLastError();
  if(dw==ERROR_FILE_NOT_FOUND){
    MessageBox("File Not Found!","Error", MB_OK);
  }
  else{
    // DeleteFile failed, but it was not because the file didn't
    // exist. Other expected results are ERROR_PATH_NOT_FOUND and
    // ERROR_ACCESS_DENIED, though you cannot in general assume
    // that the error code will be always one of these.
    // Do whatever you consider appropriate in this situtation
  }
}

This way of signaling errors (i.e., returning a BOOL and storing in case of failure an error code to be retrieved with GetLastError() ) is typical of many Win32 functions, so you might find it useful to get acquantied with it.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: Deleting a file Pin
RobJones3-Oct-01 12:53
RobJones3-Oct-01 12:53 
GeneralRe: Deleting a file Pin
Bernhard3-Oct-01 23:26
Bernhard3-Oct-01 23:26 
GeneralRe: Deleting a file Pin
RobJones4-Oct-01 7:10
RobJones4-Oct-01 7:10 
GeneralSaving file with MCI Pin
3-Oct-01 9:16
suss3-Oct-01 9:16 
QuestionHow do I get a process' opened files names Pin
Le centriste3-Oct-01 9:03
Le centriste3-Oct-01 9:03 
GeneralProblem with CDaoRecordset "Too few parameters. Expected 1" Pin
Cheickna3-Oct-01 8:21
Cheickna3-Oct-01 8:21 
GeneralRe: Problem with CDaoRecordset "Too few parameters. Expected 1" Pin
Carlos Antollini3-Oct-01 8:35
Carlos Antollini3-Oct-01 8:35 
QuestionHow to check a FTP connection's validation? Pin
Chaos Lawful3-Oct-01 6:46
Chaos Lawful3-Oct-01 6:46 
AnswerRe: How to check a FTP connection's validation? Pin
Carlos Antollini3-Oct-01 8:37
Carlos Antollini3-Oct-01 8:37 
GeneralAfxbeginThread Pin
meirav3-Oct-01 6:44
meirav3-Oct-01 6:44 
GeneralRe: AfxbeginThread Pin
Chaos Lawful3-Oct-01 6:56
Chaos Lawful3-Oct-01 6:56 
GeneralRe: AfxbeginThread Pin
meirav3-Oct-01 19:53
meirav3-Oct-01 19:53 
GeneralRe: AfxbeginThread Pin
Chaos Lawful3-Oct-01 19:56
Chaos Lawful3-Oct-01 19:56 
GeneralRe: AfxbeginThread Pin
meirav3-Oct-01 19:59
meirav3-Oct-01 19:59 
GeneralRe: AfxbeginThread Pin
Chaos Lawful3-Oct-01 22:21
Chaos Lawful3-Oct-01 22:21 
QuestionMSComm CByteArray to BStr, how do I? Pin
3-Oct-01 5:14
suss3-Oct-01 5:14 
GeneralNET DataSet Implemented in Visual C++ Pin
jawillia993-Oct-01 4:34
jawillia993-Oct-01 4:34 

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.