Is this a file specific to your app that only your app can open? Or, are you talking about any file, excel, word, etc?
A little tip, excel files fail if you try to open them in your app and they are already opened. If you used an extension .xls for your files you can eliminate flag setting when opening.
The code below fail if the .xls file is opened and tells the user. It's opened for output only using ios:

ut and deletes it's contents when opened. If I wanted to append I would use ios::app.
ofstream TextFile;
char *cSaveFilePath = "Debug.xls";
TextFile.open(cSaveFilePath, ios:

ut);
if(TextFile.fail()){
// check for file open errors
CString csFileError;
csFileError.Format("%s\n\n%s\n\n%s",
"Error opening:",
cSaveFilePath,
"Make sure the file is not in use by another application"

;
AfxMessageBox(csFileError);
return;
}