SHFileOperation
-
Hi All I am useing SHFileOperation for copy folder.It's working nice for folder.Can i use SHFileOperation for file also.I mean when i copy folder like this.
C:\\Test(Source Folder)
C:\\Test2(Deswtination folder)This is working fine. But when i copy file like this then it's not working.
C:\\log.txt(Source)
C:\\ (Destination)Plz help me:rose:
-
Hi All I am useing SHFileOperation for copy folder.It's working nice for folder.Can i use SHFileOperation for file also.I mean when i copy folder like this.
C:\\Test(Source Folder)
C:\\Test2(Deswtination folder)This is working fine. But when i copy file like this then it's not working.
C:\\log.txt(Source)
C:\\ (Destination)Plz help me:rose:
MsmVc wrote:
C:\\log.txt(Source)C:\\ (Destination)
And whats should it do (i.e. what is the expected 'working' behaviour)? :)
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] -
Hi All I am useing SHFileOperation for copy folder.It's working nice for folder.Can i use SHFileOperation for file also.I mean when i copy folder like this.
C:\\Test(Source Folder)
C:\\Test2(Deswtination folder)This is working fine. But when i copy file like this then it's not working.
C:\\log.txt(Source)
C:\\ (Destination)Plz help me:rose:
void CTestgarbageDlg::OnButton1()
{
SHFILEOPSTRUCT shop;
shop.hwnd = this->GetSafeHwnd();
shop.wFunc = FO_COPY;
shop.pFrom = _T("c:\\AUTOEXEC.BAT\0");
shop.pTo = _T("d:\0");
shop.fFlags = FOF_FILESONLY;int iRet = -1; iRet = SHFileOperation(&shop); if (iRet == 0) { //sucess AfxMessageBox(\_T("sucess")); } else { AfxMessageBox(\_T("fail")); }
}
I've tried the code above, it works fine. Hope it helps you.
-
void CTestgarbageDlg::OnButton1()
{
SHFILEOPSTRUCT shop;
shop.hwnd = this->GetSafeHwnd();
shop.wFunc = FO_COPY;
shop.pFrom = _T("c:\\AUTOEXEC.BAT\0");
shop.pTo = _T("d:\0");
shop.fFlags = FOF_FILESONLY;int iRet = -1; iRet = SHFileOperation(&shop); if (iRet == 0) { //sucess AfxMessageBox(\_T("sucess")); } else { AfxMessageBox(\_T("fail")); }
}
I've tried the code above, it works fine. Hope it helps you.
fantasy1215 wrote:
shop.pFrom = _T("c:\\AUTOEXEC.BAT\0"); shop.pTo = _T("d:\0");
Why do you double terminate the strings? Nevermind, it was my ignorance. :)
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]modified on Monday, October 6, 2008 4:38 AM
-
fantasy1215 wrote:
shop.pFrom = _T("c:\\AUTOEXEC.BAT\0"); shop.pTo = _T("d:\0");
Why do you double terminate the strings? Nevermind, it was my ignorance. :)
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]modified on Monday, October 6, 2008 4:38 AM
-
Documentation says to end it with two null chars. Rajesh has verified it it works with single null termination also.
Regards, Sandip.
SandipG :) wrote:
Rajesh has verified it it works with single null termination also.
Actually, I just said that it worked in *that particular* case, as it might work with certain cases, which cannot be predicted. But that isn't the best thing to do. Because if there is a buffer overrun, then that could be disastrous. And - Those strings must be double null-terminated. :)
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
-
Documentation says to end it with two null chars. Rajesh has verified it it works with single null termination also.
Regards, Sandip.
SandipG wrote:
Documentation says to end it with two null chars.
Thank you.
SandipG wrote:
Rajesh has verified it it works with single null termination also.
I know he likes the pragmatic approach. :)
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] -
SandipG :) wrote:
Rajesh has verified it it works with single null termination also.
Actually, I just said that it worked in *that particular* case, as it might work with certain cases, which cannot be predicted. But that isn't the best thing to do. Because if there is a buffer overrun, then that could be disastrous. And - Those strings must be double null-terminated. :)
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
You're definitely a nit-picker! :-D
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] -
SandipG :) wrote:
Rajesh has verified it it works with single null termination also.
Actually, I just said that it worked in *that particular* case, as it might work with certain cases, which cannot be predicted. But that isn't the best thing to do. Because if there is a buffer overrun, then that could be disastrous. And - Those strings must be double null-terminated. :)
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]