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. Newbie: (Safely) deleting files

Newbie: (Safely) deleting files

Scheduled Pinned Locked Moved C / C++ / MFC
htmlhelp
8 Posts 7 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.
  • B Offline
    B Offline
    blindcop
    wrote on last edited by
    #1

    Hi! In my program I have a path to a file that I want to delete. I have looked all over google and here and can't find any explanation of what code I should use to delete this file without running any risks of formatting hardrdives etc... I thought of using ShellExecute with del but was not sure if that was such a good idea. Any help greatfully received! Dom

    P V J K A 5 Replies Last reply
    0
    • B blindcop

      Hi! In my program I have a path to a file that I want to delete. I have looked all over google and here and can't find any explanation of what code I should use to delete this file without running any risks of formatting hardrdives etc... I thought of using ShellExecute with del but was not sure if that was such a good idea. Any help greatfully received! Dom

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      What is wrong with ::DeleteFile(LPCTSTR pszFileName)?


      Build a man a fire, and he will be warm for a day
      Light a man on fire, and he will be warm for the rest of his life!

      B 1 Reply Last reply
      0
      • B blindcop

        Hi! In my program I have a path to a file that I want to delete. I have looked all over google and here and can't find any explanation of what code I should use to delete this file without running any risks of formatting hardrdives etc... I thought of using ShellExecute with del but was not sure if that was such a good idea. Any help greatfully received! Dom

        V Offline
        V Offline
        Vitali Halershtein
        wrote on last edited by
        #3

        Hi Dom, Why not use DeleteFile from win32 api ? BOOL DeleteFile( LPCTSTR lpFileName // file name ); Vitali http://www.creative-case.com

        1 Reply Last reply
        0
        • P Paul M Watt

          What is wrong with ::DeleteFile(LPCTSTR pszFileName)?


          Build a man a fire, and he will be warm for a day
          Light a man on fire, and he will be warm for the rest of his life!

          B Offline
          B Offline
          blindcop
          wrote on last edited by
          #4

          Thanks:) I new it had to be simple but for some reason the simplest answers are the hardest to find answers for. Cheers Dom

          1 Reply Last reply
          0
          • B blindcop

            Hi! In my program I have a path to a file that I want to delete. I have looked all over google and here and can't find any explanation of what code I should use to delete this file without running any risks of formatting hardrdives etc... I thought of using ShellExecute with del but was not sure if that was such a good idea. Any help greatfully received! Dom

            J Offline
            J Offline
            Jonathan Craig
            wrote on last edited by
            #5

            If you wish to send files to the recycle bin instead of just deleting them, use the SHFileOperation(...) function. It is a little tricky to use, but you can do a lot of cool stuff with it. See the MSDN. Hack on!:) Jonathan Craig www.mcw-tech.com

            1 Reply Last reply
            0
            • B blindcop

              Hi! In my program I have a path to a file that I want to delete. I have looked all over google and here and can't find any explanation of what code I should use to delete this file without running any risks of formatting hardrdives etc... I thought of using ShellExecute with del but was not sure if that was such a good idea. Any help greatfully received! Dom

              K Offline
              K Offline
              keegan
              wrote on last edited by
              #6

              i always thought system("del file.txt") was efficient. :) *.* cin >> knowledge;

              J 1 Reply Last reply
              0
              • K keegan

                i always thought system("del file.txt") was efficient. :) *.* cin >> knowledge;

                J Offline
                J Offline
                joshfl
                wrote on last edited by
                #7

                int unlink(const char*) works too :) todo.... :: insert inpirational text here ::

                1 Reply Last reply
                0
                • B blindcop

                  Hi! In my program I have a path to a file that I want to delete. I have looked all over google and here and can't find any explanation of what code I should use to delete this file without running any risks of formatting hardrdives etc... I thought of using ShellExecute with del but was not sure if that was such a good idea. Any help greatfully received! Dom

                  A Offline
                  A Offline
                  Alexander M
                  wrote on last edited by
                  #8

                  the typical newbie... they always want to code things much too difficult for them... i know that feeling... Don't try it, just do it! ;-)

                  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