|
-
Jun 23rd, 2001, 05:04 PM
#1
Thread Starter
Hyperactive Member
copyfile
Code:
int dirwalk(char *path)
{
WIN32_FIND_DATA WFD;
HANDLE fhwnd;
BOOL fhwndN;
string str1;
string str2;
string str;
fhwnd = FindFirstFile(path, &WFD);
str1 = "D:\"
str2 = WFD.cFileName;
str = str1 + str2;
CopyFile(WFD.cFileName,str,FALSE);
do{
fhwndN = FindNextFile(fhwnd,&WFD);
CopyFile(WFD.cFileName,str,FALSE);
}
while(fhwndN!=0);
return 0;
}
The errors I get here are:
C:\MATT\MVC++\MSDEV98\MyProjects\copyfile\copyfile.cpp(122) : error C2001: newline in constant
C:\MATT\MVC++\MSDEV98\MyProjects\copyfile\copyfile.cpp(123) : error C2146: syntax error : missing ';' before identifier 'str2'
C:\MATT\MVC++\MSDEV98\MyProjects\copyfile\copyfile.cpp(126) : error C2664: 'CopyFileA' : cannot convert parameter 2 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\MATT\MVC++\MSDEV98\MyProjects\copyfile\copyfile.cpp(130) : error C2664: 'CopyFileA' : cannot convert parameter 2 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
Im trying to use the STL to ease the use of strings here, but now it seems there format does not work with CopyFile parameters.
Anyway any help is appreciated. Thanks
Matt 
-
Jun 23rd, 2001, 05:35 PM
#2
Monday Morning Lunatic
Use:
Code:
string x = "hello";
printf(x.c_str());
Also, '\' is the escape character, so you need "D:\\". Oh, and you missed a semicolon
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 23rd, 2001, 06:03 PM
#3
Thread Starter
Hyperactive Member
Matt 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|