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. CFile

CFile

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++databaseannouncement
4 Posts 3 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.
  • V Offline
    V Offline
    vc programmer 0
    wrote on last edited by
    #1

    how to update CFile in vc++. i want to change data. (for example) //existing data dataid=1 datades=data1 //updating data dataid=1 datades=dataone CFile is like as sql have new,delete,update. i know only create file, read file. i don't know update file. vc++ have update file or not.

    Y V 2 Replies Last reply
    0
    • V vc programmer 0

      how to update CFile in vc++. i want to change data. (for example) //existing data dataid=1 datades=data1 //updating data dataid=1 datades=dataone CFile is like as sql have new,delete,update. i know only create file, read file. i don't know update file. vc++ have update file or not.

      Y Offline
      Y Offline
      ytod
      wrote on last edited by
      #2

      The Simplest way to do so is to open the file again and then write your new data. Actually, I always did so in the following way...;P SOMETYPE SomeFunction() { CFile l_File; // local CFile object l_File.Open( "C:\\FileName.txt", CFile::modeCreate | CFile::modeReadWrite ); // using the open flags CFile::modeCreate OR CFile::modeReadWrite // wrting your file by calling CFile::Write() ... }

      V 1 Reply Last reply
      0
      • Y ytod

        The Simplest way to do so is to open the file again and then write your new data. Actually, I always did so in the following way...;P SOMETYPE SomeFunction() { CFile l_File; // local CFile object l_File.Open( "C:\\FileName.txt", CFile::modeCreate | CFile::modeReadWrite ); // using the open flags CFile::modeCreate OR CFile::modeReadWrite // wrting your file by calling CFile::Write() ... }

        V Offline
        V Offline
        vc programmer 0
        wrote on last edited by
        #3

        Sir... my existing create code is following.. void ARMManagementRecords::SaveDomains() { // For domains BOOL bCanSave = FALSE; UINT nFlags = CFile::typeBinary | CFile::modeWrite; // file doesn't exist, so create it if (_access(DATA_FILE_DOMAIN, 0)) { nFlags |= CFile::modeCreate; bCanSave = TRUE; } else { bCanSave = CanSerializeDomain(); } if (bCanSave) { CFile file; CFileException fe; // file exists with read & write permissions if (file.Open(DATA_FILE_DOMAIN, nFlags, &fe)) { CArchive arDomain(&file, CArchive::store); //CStringArray m_domainArray; m_domainArray.Serialize(arDomain); } file.Close(); } }

        1 Reply Last reply
        0
        • V vc programmer 0

          how to update CFile in vc++. i want to change data. (for example) //existing data dataid=1 datades=data1 //updating data dataid=1 datades=dataone CFile is like as sql have new,delete,update. i know only create file, read file. i don't know update file. vc++ have update file or not.

          V Offline
          V Offline
          vcplusplus
          wrote on last edited by
          #4

          vc-programmer- wrote: CFile is like as sql have new,delete,update. Here is a list of all the methods for CFile. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cfile_class_members.asp[^]

          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