Results 1 to 3 of 3

Thread: copyfile

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    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

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    thanks!
    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
  •  



Click Here to Expand Forum to Full Width