Copy a Folder

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2009
Posts: 6
Reputation: pigg is an unknown quantity at this point 
Solved Threads: 0
pigg pigg is offline Offline
Newbie Poster

Re: Copy a Folder

 
0
  #11
Feb 17th, 2009
Originally Posted by niek_e View Post
Here's the MSDN page for SHFileOperation. At the bottom of the page are all the error-codes (return values). So what value does it return in your case?
Print out the value of 'n' in the else statement to find out and thus find out what went wrong.
Thanks so much for your reply.
Yes, as your advice, i add the output of "n",
the result is "1026".(it should be 0x402)

By the MSDN:
0x402 An unknown error occurred. This is typically due to an invalid path in the source or destination. This error does not occur on Windows Vista and later.

So i guess the fail may from the "invalid path". is it right?
(But in my PC, the path is true, with out any problem.)
Could you help me and give me some suggestions?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 978
Reputation: mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice 
Solved Threads: 208
mitrmkar mitrmkar is offline Offline
Posting Shark

Re: Copy a Folder

 
1
  #12
Feb 17th, 2009
Originally Posted by pigg View Post
Yes, as your advice, i add the output of "n",
the result is "1026".(it should be 0x402)

By the MSDN:
0x402 An unknown error occurred. This is typically due to an invalid path in the source or destination. This error does not occur on Windows Vista and later.

So i guess the fail may from the "invalid path". is it right?
(But in my PC, the path is true, with out any problem.)
Both the pFrom and pTo members need to be double-null terminated, see the
SHFILEOPSTRUCT Structure documentation.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 6
Reputation: pigg is an unknown quantity at this point 
Solved Threads: 0
pigg pigg is offline Offline
Newbie Poster

Re: Copy a Folder

 
0
  #13
Feb 24th, 2009
Thank you so much for your advice.

The problem is solved.
I have add a "\0" to the end of the string, which should be a double null terminated(i think).
anyway, here is the solution:
  1. std::string testto = "d:\\testto"
  2. SHFILEOPSTRUCT sf;
  3. memset(&sf,0,sizeof(sf));
  4. sf.hwnd = 0;
  5. sf.wFunc = FO_COPY;
  6. sf.pFrom = "d:\\testfrom";
  7. char d_te[] = "\0";
  8. std::string to = testto;
  9. to.append(d_te);
  10. sf.pTo = (LPCSTR) to.c_str();
  11. sf.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_SILENT;
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC