sriamar
asked on
Including space in path for windows 2000
Hi,
I have to copy a file form one location to another using c++ in windows 2000. I have the following code.
//I use the CFileDialog Dlg to get the file location
szFilename = Dlg.GetPathName();
destfile = "C:\pic.bmp";
char syscommand[350];
sprintf(syscommand,"copy %s %s",szFilename,destfile);
AfxMessageBox(syscommand);
int i = system(syscommand);
if(i != 0)
{
AfxMessageBox( "Could not copy because file is in desktop or file name has space in between");
}
when the source file is in desktop......then the path wil be
c:\Documents ans Settings\Administrator\Des ktop\pic.b mp but as windows 2000 represents it as
C:\DOCUME~1\ADMINI~1\DESKT OP my code above doesnt work.
How do I solve this problem. Thankyou
Amar
I have to copy a file form one location to another using c++ in windows 2000. I have the following code.
//I use the CFileDialog Dlg to get the file location
szFilename = Dlg.GetPathName();
destfile = "C:\pic.bmp";
char syscommand[350];
sprintf(syscommand,"copy %s %s",szFilename,destfile);
AfxMessageBox(syscommand);
int i = system(syscommand);
if(i != 0)
{
AfxMessageBox( "Could not copy because file is in desktop or file name has space in between");
}
when the source file is in desktop......then the path wil be
c:\Documents ans Settings\Administrator\Des
C:\DOCUME~1\ADMINI~1\DESKT
How do I solve this problem. Thankyou
Amar
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
Yea The problem was converting long file name to the short file name. Once I saw GetLongPathName i found the "GetShortPathName(...)" and it did the trick.Thanks a lot Jimwasson
and jaime_olivares thanks for ur answer. sprintf i have mentioned above works and I see no problem with it.
Thankyou guys
amar
Yea The problem was converting long file name to the short file name. Once I saw GetLongPathName i found the "GetShortPathName(...)" and it did the trick.Thanks a lot Jimwasson
and jaime_olivares thanks for ur answer. sprintf i have mentioned above works and I see no problem with it.
Thankyou guys
amar
sprintf(syscommand,"copy \"%s\" \"%s\"",szFilename,destfil