function _findfirst with a pathname containing a blank

H

hpber

Hello,
I try to check the existence of a file with the function
_findfirst(...).
The file is located in a directory with a blank in its path name: C:
\Program Files\ExtPrg.exe

When I run the following code:
char FilePath[]="C:\\\"Program Files\"\\ExtPrg.exe";
hFile = _findfirst( FilePath, &c_file );
system (FilePath);
the _findfirst function returns -1 which means that the file is not
found, but the following system command starts the file.
So can anybody tell me, how I have to enter FilePath in a way that the
_findfirst function works?

Thank you.
 
C

Chris Dollin

hpber said:
Hello,
I try to check the existence of a file with the function
_findfirst(...).

(There's no such function in Standard C, so you're using some kind
of extension: you may get more help by appealing in a group
appropriate to your system.)
The file is located in a directory with a blank in its path name: C:
\Program Files\ExtPrg.exe

(We hatess pathnames with ssspaces in, preciousss!)
When I run the following code:
char FilePath[]="C:\\\"Program Files\"\\ExtPrg.exe";

Um. If the pathname you want is

C:\Program Files\ExtPrg.exe

why have you coded up a pathname

C:\"Program Files"\ExtPrg.exe

??? You've put double-quotes into your pathname using the \" escape.
 
R

Richard Heathfield

hpber said:
Hello,
I try to check the existence of a file with the function
_findfirst(...).
The file is located in a directory with a blank in its path name: C:
\Program Files\ExtPrg.exe

Try comp.os.ms-windows.programmer.win32
 
T

Tor Rustad

hpber said:
Hello,
I try to check the existence of a file with the function
_findfirst(...).

Functions prefixed with a "_", is a reminder that you are off-topic in
c.l.c.
The file is located in a directory with a blank in its path name: C:
\Program Files\ExtPrg.exe
When I run the following code:
char FilePath[]="C:\\\"Program Files\"\\ExtPrg.exe";

I prefer to write filenames with path this way:

fopen("C:/Program Files/ExtPrg.exe", "r")

aka UNIX like, but works on Win32 as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top