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 761195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:48:32+00:00 2026-05-14T15:48:32+00:00

I am using Visual C++. How to copy the content of this file to

  • 0

I am using Visual C++. How to copy the content of this file to another file?

UINT32 writeToLog(wstring log)
 {
    wfstream file1 (LOG_FILE_NAME, ios_base::out);  
    file1 << log;       
    file1.close();

     // want to copy file1 to file2

     return 0;
 }
  • 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-14T15:48:33+00:00Added an answer on May 14, 2026 at 3:48 pm

    What exactly do you want to do? If you need a copy of the data, you can read it in and write it back out again. If you really need a copy of the file, you have to use OS specific calls.

    In many cases, reading in the file data and then writing it out again to a different file is a close enough approximation to a copy – like this:

    ifstream file1(...);
    ofstream file2(...);
    std::copy(istream_iterator<char>(file1),istream_iterator<char>(),ostream_iterator<char>(file2));
    

    However that really isn’t a copy – it’s creating a new file with the same contents. It won’t correctly handle hard links or symlinks, it won’t correctly handle metadata and it will only ‘copy’ the default file stream.

    If you need a file copy on Windows you should call one of CopyFile, CopyFileEx or CopyFileTransacted depending on your exact requirements.

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

Sidebar

Related Questions

I am using Visual Studio 2008 professional, C#. I found the App.config file is
THIS XAMLParseException IS DRIVING ME CRAZY!! I am using .NET 3.5 in Visual Studio
I'm currently using Visual Studio 2010 (and also have a copy of Visual Studio
I am using Visual Studio 2010 and I have a simple XML file which
I'm trying to copy and past a form within a project using Visual Studio.
Using Visual Studio 2008, I created a C++ Win32 project. To release the program,
Using Visual Studio 2005 As per the title; MSDN and google can't tell me,
Using Visual Studio 2005, I wrote a simple DLL in C that uses the
Using visual studio 2008, I had a solution open and realized I need to
(Using Visual Studio 2005 / .NET 2.0) I have a DataSet which is being

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.