Problem in .exe copy
-
Actually
GetLastError
returns a number. Please post the code wherein the error occurs and report the error exactly as it stands. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]USES_CONVERSION;
CString FileName; //Source pathCString
cs; //Destination path
CString CStrfilename=FileName;
char* charfilename;
charfilename=CStrfilename.GetBuffer();
LPCTSTR lp;
lp=CStrfilename;
PathSkipRoot(lp);
cs = "\\BackUp\\";
cs += PathSkipRoot(lp);
//CString st;
//AfxMessageBox(cs);
// CopyFile(st, cs,TRUE);
DWORD dwError = GetLastError();
CopyFile(FileName, cs,TRUE);
AfxMessageBox(dwError); -
USES_CONVERSION;
CString FileName; //Source pathCString
cs; //Destination path
CString CStrfilename=FileName;
char* charfilename;
charfilename=CStrfilename.GetBuffer();
LPCTSTR lp;
lp=CStrfilename;
PathSkipRoot(lp);
cs = "\\BackUp\\";
cs += PathSkipRoot(lp);
//CString st;
//AfxMessageBox(cs);
// CopyFile(st, cs,TRUE);
DWORD dwError = GetLastError();
CopyFile(FileName, cs,TRUE);
AfxMessageBox(dwError); -
USES_CONVERSION;
CString FileName; //Source pathCString
cs; //Destination path
CString CStrfilename=FileName;
char* charfilename;
charfilename=CStrfilename.GetBuffer();
LPCTSTR lp;
lp=CStrfilename;
PathSkipRoot(lp);
cs = "\\BackUp\\";
cs += PathSkipRoot(lp);
//CString st;
//AfxMessageBox(cs);
// CopyFile(st, cs,TRUE);
DWORD dwError = GetLastError();
CopyFile(FileName, cs,TRUE);
AfxMessageBox(dwError);vcprog wrote:
// CopyFile(st, cs,TRUE); DWORD dwError = GetLastError(); CopyFile(FileName, cs,TRUE); AfxMessageBox(dwError);
Please replace the above sequence with the following
if ( CopyFile(FileName, cs, TRUE) != TRUE)
{
DWORD dwError = GetLastError();
CString szMsg;
szMsg.Format("Error number %d", dwError);
AfxMessageBox(szMsg);
}
else
{
AfxMessageBox("Success");
}and post the output.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles] -
vcprog wrote:
// CopyFile(st, cs,TRUE); DWORD dwError = GetLastError(); CopyFile(FileName, cs,TRUE); AfxMessageBox(dwError);
Please replace the above sequence with the following
if ( CopyFile(FileName, cs, TRUE) != TRUE)
{
DWORD dwError = GetLastError();
CString szMsg;
szMsg.Format("Error number %d", dwError);
AfxMessageBox(szMsg);
}
else
{
AfxMessageBox("Success");
}and post the output.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles] -
vcprog wrote:
// CopyFile(st, cs,TRUE); DWORD dwError = GetLastError(); CopyFile(FileName, cs,TRUE); AfxMessageBox(dwError);
Please replace the above sequence with the following
if ( CopyFile(FileName, cs, TRUE) != TRUE)
{
DWORD dwError = GetLastError();
CString szMsg;
szMsg.Format("Error number %d", dwError);
AfxMessageBox(szMsg);
}
else
{
AfxMessageBox("Success");
}and post the output.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles] -
USES_CONVERSION;
CString FileName; //Source pathCString
cs; //Destination path
CString CStrfilename=FileName;
char* charfilename;
charfilename=CStrfilename.GetBuffer();
LPCTSTR lp;
lp=CStrfilename;
PathSkipRoot(lp);
cs = "\\BackUp\\";
cs += PathSkipRoot(lp);
//CString st;
//AfxMessageBox(cs);
// CopyFile(st, cs,TRUE);
DWORD dwError = GetLastError();
CopyFile(FileName, cs,TRUE);
AfxMessageBox(dwError);cpallini wrote:
Please post the code wherein the error occurs and report the error exactly as it stands.
vcprog wrote:
DWORD dwError = GetLastError(); CopyFile(FileName, cs,TRUE); AfxMessageBox(dwError);
Aye, aye, aye! As stated above, GetLastError returns an integer. You then need to use this integer IN CONJUNCTION WITH FormatMessage to get a printable text string. If you have a look here, you can see an example of use for the two functions: http://msdn.microsoft.com/en-us/library/ms680582(VS.85).aspx[^] We will "please help", so long as you will "please read".....
-
Error no. 32 for .exe file and Error no. 3 for .txt file. But .txt file is copy file is Success. Plz help me
haha~ The error number is exactly the same as that we have expected. Click Tools >> error Lookup,enter the error number, then you may have the answer.
You know some birds are not meant to be caged, their feathers are just too bright.
-
haha~ The error number is exactly the same as that we have expected. Click Tools >> error Lookup,enter the error number, then you may have the answer.
You know some birds are not meant to be caged, their feathers are just too bright.
-
Error no. 32 for .exe file and Error no. 3 for .txt file. But .txt file is copy file is Success. Plz help me
from WinError.h
//
// MessageId: ERROR_PATH_NOT_FOUND
//
// MessageText:
//
// The system cannot find the path specified.
//
#define ERROR_PATH_NOT_FOUND 3Land
//
// MessageId: ERROR_SHARING_VIOLATION
//
// MessageText:
//
// The process cannot access the file because it is being used by another process.
//
#define ERROR_SHARING_VIOLATION 32LI think they're quite explanatory. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
thx's for reply.. Error is
The process cannot access the file because it is being used by another process.
Plz help me
i find your problem is not to programe,is to use the computer.
You know some birds are not meant to be caged, their feathers are just too bright.