Hi,
I am using the following code to copy a file from one source folder to a destination folder
this works fine if the directories are on a local drive, however I have to move the file from the local tmp directory to a directory on a mounted file system, what changes do I have to make in the above code to achieve this.
Also I want some error checking to be sure that the file has been copied successfully to the destination directory.
Thanks in advance,
tewari
I am using the following code to copy a file from one source folder to a destination folder
Code:
string filname;
string::size_type start = emailDestination.find("tmp/");
string::size_type end = emailDestination.find("\n");
filname = emailDestination.substr(start + 4,end);
cout << "fileName is : " << filname << endl;
finalEmailDestination = finalEmailDestination + filname;
char ch;
std::ifstream infile;
std::ofstream outfile;
filebuf *inbuf, *outbuf;
infile.open (emailDestination.c_str(), ios::in);
outfile.open (finalEmailDestination.c_str(), ios::out);
inbuf=infile.rdbuf();
outbuf=outfile.rdbuf();
ch = inbuf->sgetc();
while ( ch != EOF)
{
outbuf->sputc (ch);
ch= inbuf->snextc();
}
Also I want some error checking to be sure that the file has been copied successfully to the destination directory.
Thanks in advance,
tewari