470,573 Members | 1,821 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

function _findfirst with a pathname containing a blank

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.

Apr 25 '07 #1
3 5084
hpber wrote:
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.

--
"No-one here is exactly what he appears." G'kar, /Babylon 5/

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Apr 25 '07 #2
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

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Apr 25 '07 #3
hpber wrote:
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.

--
Tor
Apr 25 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by b1azesk | last post: by
3 posts views Thread by Anna | last post: by
2 posts views Thread by Fernando Barsoba | last post: by
reply views Thread by drhowarddrfine | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.