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 to Delete a used file in C++?

How to Delete a used file in C++?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
10 Posts 5 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.
  • 0 Offline
    0 Offline
    002comp
    wrote on last edited by
    #1

    Hello Friends I m using remove(filename);but how i can delete if it using somewhere in project means is there any way that if i free that file and do this remove command.Or is there any other method to delete the file? Thanks & Regards Yogesh

    J D M 3 Replies Last reply
    0
    • 0 002comp

      Hello Friends I m using remove(filename);but how i can delete if it using somewhere in project means is there any way that if i free that file and do this remove command.Or is there any other method to delete the file? Thanks & Regards Yogesh

      J Offline
      J Offline
      Jerry Wang
      wrote on last edited by
      #2

      How about MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT?

      0 1 Reply Last reply
      0
      • J Jerry Wang

        How about MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT?

        0 Offline
        0 Offline
        002comp
        wrote on last edited by
        #3

        I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason? Thanks

        _ D J 3 Replies Last reply
        0
        • 0 002comp

          I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason? Thanks

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          Try _unlink

          «_Superman_» I love work. It gives me something to do between weekends.

          0 1 Reply Last reply
          0
          • _ _Superman_

            Try _unlink

            «_Superman_» I love work. It gives me something to do between weekends.

            0 Offline
            0 Offline
            002comp
            wrote on last edited by
            #5

            _unlink is also not working dear.Please suggest me some other solution.

            0 1 Reply Last reply
            0
            • 0 002comp

              _unlink is also not working dear.Please suggest me some other solution.

              0 Offline
              0 Offline
              002comp
              wrote on last edited by
              #6

              Reply Guys Any solution.

              1 Reply Last reply
              0
              • 0 002comp

                I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason? Thanks

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

                yogeshs wrote:

                I used this but it is not working bro.

                And did you call GetLastError() to find out why?

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                1 Reply Last reply
                0
                • 0 002comp

                  Hello Friends I m using remove(filename);but how i can delete if it using somewhere in project means is there any way that if i free that file and do this remove command.Or is there any other method to delete the file? Thanks & Regards Yogesh

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

                  yogeshs wrote:

                  but how i can delete if it using somewhere in project...

                  Define using?

                  "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  1 Reply Last reply
                  0
                  • 0 002comp

                    Hello Friends I m using remove(filename);but how i can delete if it using somewhere in project means is there any way that if i free that file and do this remove command.Or is there any other method to delete the file? Thanks & Regards Yogesh

                    M Offline
                    M Offline
                    Maximilien
                    wrote on last edited by
                    #9

                    I assume "using" means that it's "open"ed and you still want to delete it nonetheless. You could try "ShFileOperation".

                    This signature was proudly tested on animals.

                    1 Reply Last reply
                    0
                    • 0 002comp

                      I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason? Thanks

                      J Offline
                      J Offline
                      Jerry Wang
                      wrote on last edited by
                      #10

                      When u create/open the file, try to specify the FILE_SHARE_DELETE parameter.

                      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