Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFile::Open and paths with spaces

Status
Not open for further replies.

dcswee

Programmer
Jan 23, 2002
13
GB
Riddle me this... I have a file thats name has 2 spaces in a row (eg "filename with whitespace". It wont open using the code below. I can access the file from explorer on the machine im testing but cant do it using this code, OR get any meaningful errors back from the exception.

CFileException cFileEx;
if ( !m_fileIn.Open(sFilename,CFile::modeRead,&cFileEx) )
{
TCHAR sErr[255];
BOOL bGotErr = cFileEx.GetErrorMessage(sErr,255);
cerr << &quot;Failed to open \&quot;&quot; << sFilename << &quot;\&quot;&quot; << sErr << endl;
return FALSE;
}

I would like to know why CFile::Open returns FALSE but does not do anything with cFileEx (sErr is empty) ????

 
what is the exact path and file name you are passing in there?
 
The file path was
&quot;FW RA RECEIVES APPLICATION.txt&quot;

The problem Ive now realised is, its passed by a batch file that detects it by doing

for %%f in (*.txt) do call preproc &quot;%%f&quot;

By the time 'preproc' passes it to my application, the double space has disappeared!!! Here's the call from preproc.bat to my app:

retcode ppNotice e M \%1

The reason I thought it couldnt find my file, is that for some reason its now trying to open &quot;FW RA RECEIVES APPLICATION.txt&quot; (note the single space).

Where can I find details on parameters and how they are passed in bat files?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top