Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 832481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:22:09+00:00 2026-05-15T04:22:09+00:00

How to copy a folder from one drive to other drive in VC++ …?

  • 0

How to copy a folder from one drive to other drive in VC++ …?

I have come this far

   String^ SourcePath = Directory::GetCurrentDirectory();
   String^ DestinationPath = "c:\\Test";
   CString s(SourcePath) ;
   CString d(DestinationPath);
   Directory::CreateDirectory(DestinationPath);

 SHFILEOPSTRUCT*  pFileStruct = new SHFILEOPSTRUCT;
 ZeroMemory(pFileStruct, sizeof(SHFILEOPSTRUCT)); 
 pFileStruct->hwnd  = NULL;
 pFileStruct->wFunc = FO_COPY;
 pFileStruct->pFrom = (LPCWSTR)s;//"D:\test_documents\test1.doc"; 
 pFileStruct->pTo =  (LPCWSTR)d; 
 pFileStruct->fFlags = FOF_SILENT  | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR ; 
 bool i = pFileStruct->fAnyOperationsAborted ;
 int status = SHFileOperation(pFileStruct);

 if(status == 0)
 {
           return true;
 }
 return false;

the status is showing 2 instead of zero , can some one tell me why..?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:22:10+00:00Added an answer on May 15, 2026 at 4:22 am

    Usually a String^ points to a managed string object. The SHFILOPSSTRUCT must befilled with pointers to unmanaged wchar_t. So you must pin the strings and convert. You tried to use the CString class as conversion helper.

    Use the PtrToStringChars instead to get valid strings in pTo and pFrom:
    http://msdn.microsoft.com/en-us/library/d1ae6tz5(VS.80).aspx

    The read of the fAnyOperationsAborted member is not required for the operation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to copy quite a lot of files from one folder to another.
I need to copy a Folder from one drive to a removable Hard disk.
I have a java code for copy file from one folder to another folder.
I've got about 3 million files I need to copy from one folder to
What I am trying to do is copy files from one folder to another.
Hi I need to copy the filename of xls files from one folder. Please
I have a zip file which has one base folder inside it with other
i want to copy all files and folders from one drive to another drive
I want to copy a txt file from one folder to another. While coping
I am writing an ASP file to copy file from one folder to another:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.