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. Deleting a text file after repalcing all char in a random number

Deleting a text file after repalcing all char in a random number

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonlounge
9 Posts 6 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.
  • K Offline
    K Offline
    kamalesh82
    wrote on last edited by
    #1

    Hi all, I need to open a file using Win 32(MFC API).. read each line from it, and after reading all the line i've to replace each char in the file with a random number.. after that i've to delete that file.... It's very urgent..i'll be very grateful if anyone provide the solution.... bye

    kamalesh

    D _ Z M 4 Replies Last reply
    0
    • K kamalesh82

      Hi all, I need to open a file using Win 32(MFC API).. read each line from it, and after reading all the line i've to replace each char in the file with a random number.. after that i've to delete that file.... It's very urgent..i'll be very grateful if anyone provide the solution.... bye

      kamalesh

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Since the net result is to delete the file, why bother with the character replacement? In any case, just use DeleteFile().


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      S 1 Reply Last reply
      0
      • K kamalesh82

        Hi all, I need to open a file using Win 32(MFC API).. read each line from it, and after reading all the line i've to replace each char in the file with a random number.. after that i've to delete that file.... It's very urgent..i'll be very grateful if anyone provide the solution.... bye

        kamalesh

        _ Offline
        _ Offline
        _AnsHUMAN_
        wrote on last edited by
        #3

        kamalesh82 wrote:

        I need to open a file using Win 32(MFC API

        Is opening the file in WIN32 a problem to you. You can use simple FILE * to read/write to the file.

        kamalesh82 wrote:

        read each line from it

        Use fgets, fgetc etc as per your preference.

        kamalesh82 wrote:

        after reading all the line i've to replace each char in the file with a random number

        Why so? You can read a line and change the character values simultaneously.For this you can create a temporary file in your applications directory and keep on writing that random data in the temp file. When you are done with the reading of the file you can first delete the original file and then rename the temp file.

        kamalesh82 wrote:

        after that i've to delete that file....

        BOOL DeleteFile( LPCTSTR lpFileName );

        Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

        1 Reply Last reply
        0
        • D David Crow

          Since the net result is to delete the file, why bother with the character replacement? In any case, just use DeleteFile().


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          S Offline
          S Offline
          Steve S
          wrote on last edited by
          #4

          Because the OP is wanting to overwrite the data and thus prevent the file from being undeleted later. IIRC, there was a tool in the 'Norton Tools' set that did just this. They've obviously never seen a computer forensics expert recover data from a hard drive by tweaking the controller board's currents :)

          Steve S Developer for hire

          1 Reply Last reply
          0
          • K kamalesh82

            Hi all, I need to open a file using Win 32(MFC API).. read each line from it, and after reading all the line i've to replace each char in the file with a random number.. after that i've to delete that file.... It's very urgent..i'll be very grateful if anyone provide the solution.... bye

            kamalesh

            Z Offline
            Z Offline
            Zac Howland
            wrote on last edited by
            #5

            Are you trying to write your own PGP Wipe?

            If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

            1 Reply Last reply
            0
            • K kamalesh82

              Hi all, I need to open a file using Win 32(MFC API).. read each line from it, and after reading all the line i've to replace each char in the file with a random number.. after that i've to delete that file.... It's very urgent..i'll be very grateful if anyone provide the solution.... bye

              kamalesh

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              How are you going to guarantee that the system writes the random bytes over the original bytes on the disk??

              K 1 Reply Last reply
              0
              • M Mark Salsbery

                How are you going to guarantee that the system writes the random bytes over the original bytes on the disk??

                K Offline
                K Offline
                kamalesh82
                wrote on last edited by
                #7

                i just want "secure deletion"... if i just delete , the data used in the file is very much recoverable, untill the same space of the hard disc is overwritten( as the space is holding the data)... that's y i need to change every char in the file by a random generated numbers

                kamalesh

                M 2 Replies Last reply
                0
                • K kamalesh82

                  i just want "secure deletion"... if i just delete , the data used in the file is very much recoverable, untill the same space of the hard disc is overwritten( as the space is holding the data)... that's y i need to change every char in the file by a random generated numbers

                  kamalesh

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  Right I understand but using regular file APIs you have no gaurantee that your random data will be written back to the disk at the same spot. The "old" data could (and most likely WILL) be able to still be seen on the hard drive for an indefinite amount of time. To really pull this off I'm pretty sure you need to work with the disk at a lower level than file APIs. Mark

                  1 Reply Last reply
                  0
                  • K kamalesh82

                    i just want "secure deletion"... if i just delete , the data used in the file is very much recoverable, untill the same space of the hard disc is overwritten( as the space is holding the data)... that's y i need to change every char in the file by a random generated numbers

                    kamalesh

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    This may be of interest to you for Windows 2000 and above... How To Use Cipher.exe to Overwrite Deleted Data in Windows[^]

                    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