Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do you make a physical copy of a file through CFile class?

How do you make a physical copy of a file through CFile class?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tm
    wrote on last edited by
    #1

    The scenario is that I have a file xyz.ini and I want to make a backup of it called xyz.ini2 and then rewrite to xyz. I have tried CFile::Rename and CFile::Duplicate and I am getting "a sharing violation occured while accessing an unnamed file". CFile temporiginifile; temporiginifile.Open(m_sFileFullPathName,CFile::modeReadWrite|CFile::shareDenyNone); temporiginifile.Rename(m_sFileFullPathName,m_sFileFullPathName+"2"); temporiginifile.Close(); Paradise is where I am. Voltaire

    T 1 Reply Last reply
    0
    • T tm

      The scenario is that I have a file xyz.ini and I want to make a backup of it called xyz.ini2 and then rewrite to xyz. I have tried CFile::Rename and CFile::Duplicate and I am getting "a sharing violation occured while accessing an unnamed file". CFile temporiginifile; temporiginifile.Open(m_sFileFullPathName,CFile::modeReadWrite|CFile::shareDenyNone); temporiginifile.Rename(m_sFileFullPathName,m_sFileFullPathName+"2"); temporiginifile.Close(); Paradise is where I am. Voltaire

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Just use CopyFile API function. All you need to do is to pass the filenames. Tomasz Sowinski -- http://www.shooltz.com

      T 1 Reply Last reply
      0
      • T Tomasz Sowinski

        Just use CopyFile API function. All you need to do is to pass the filenames. Tomasz Sowinski -- http://www.shooltz.com

        T Offline
        T Offline
        tm
        wrote on last edited by
        #3

        Thanks. Paradise is where I am. Voltaire

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups