CPB Mailing List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's wrong with my codes?(REV)



Correction>>The meaning of the int>>

CopyFile(const char*, const char*, int)
as for the int>>
Its a trick question, rather the flag is for "Fail if Exists".
So TRUE would mean you want the function to fail, returning zero if the
newfile exists.
And FALSE would mean you want it to overwrite the existing file if it
exists.
Sort of backwards it seems...

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    String WinDir = "c:\\windows\\";
    String name = "Rick";
    String pwlfile = WinDir + name +".pwl";
    String dllfile = WinDir + "OCX255" + name + ".dll";
    char *oldfile = pwlfile.c_str();
    char *newfile = dllfile.c_str();
    if(CopyFile(oldfile, newfile, TRUE))
	{
	    ShowMessage("Copy completed.");
	}
    else
	{
	ShowMessage("File already exists.");
	}
}
Rick Malik
rmfci@pacbell.net
"Visit the C++ Builder Hobby Pages"
http://home.pacbell.net/rmfci/bcbhp.htm


W Komornicki's Home Page | Main Index | Thread Index