Jun 30, 2009 at 4:44am UTC
hello all i hae written following program to copy entire folder
in c++ , it works on my pc where i develope it . but when i copy
exe to my friends computer it fails gives error configuration
incorrect . can anyone help ? thanks in advance .
sending program also ->
#include<iostream>
#include<windows.h>
#include<string>
using namespace std;
string root;
void getallfiles(string s ,string dest)
{
HANDLE hFind;
WIN32_FIND_DATA finddata;
hFind = FindFirstFileA( s.c_str() , &finddata);
if (hFind == INVALID_HANDLE_VALUE)
return ;
string rep = "*";
do
{
string::size_type idx = s.find(rep);
rep = finddata.cFileName;
string temp(s,idx,s.length());
s.replace(idx,temp.length(),finddata.cFileName);
//cout<<s<<"\n";
idx = s.length() - root.length();
string temp2 = s;
temp2.replace(0 , root.length() ,dest);
//cout<<temp2<<"\n";
idx = temp2.find('.');
if(idx == string::npos)
{
//cout<< "creating "<<temp2<<"\n";
CreateDirectory(temp2.c_str(),NULL);
}
if(CopyFile(s.c_str(),temp2.c_str(),true))
{
;
}
else
{
//cout<<"error "<<GetLastError()<<"\n";
}
s = s + "\\*";
if( (rep != ".") && (rep != ".."))
{
getallfiles( s.c_str() , dest );
}
}while(FindNextFile (hFind, &finddata));
}
void main()
{
string sou;
string dest;
cout<<"enter source \n";
getline(cin,sou);
root = sou + "\\";
sou = sou + "\\*";
cout<<"enter destination \n";
getline(cin,dest);
CreateDirectoryEx("f:\\my",dest.c_str(),NULL);
dest = dest + "\\";
HWND h = FindWindow("ConsoleWindowClass",NULL);
system("cls");
ShowWindow(h,SW_HIDE);
getallfiles(sou , dest);
ShowWindow(h,SW_RESTORE);
system("pause");
}
Last edited on Jul 2, 2009 at 4:45am UTC
Jun 30, 2009 at 9:13am UTC
What compiler are you using?
Jul 2, 2009 at 4:44am UTC
sorry i furgate to tell compiler name
i am using microsoft visual studio 2005 .
Last edited on Jul 2, 2009 at 4:45am UTC
Jul 2, 2009 at 5:03am UTC
Google "visual c++ 2005 runtime redist". One of the top results will be a download page from Microsoft. The people you give your program to need to install that in order to run your program.
Jul 3, 2009 at 5:49am UTC
Another thing. WHERE in the world are you living and WHERE is your friend?
I had the same problem, and when I fixed it like that, it still didn't work on an american PC. I live in Norway.