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#
  4. delete a file automatically

delete a file automatically

Scheduled Pinned Locked Moved C#
csharp
7 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.
  • L Offline
    L Offline
    lawrenceinba
    wrote on last edited by
    #1

    hi; is there any coding for deleting a particular file in specified period of time automatically in c#

    the quieter u become more u hear

    L A OriginalGriffO realJSOPR 4 Replies Last reply
    0
    • L lawrenceinba

      hi; is there any coding for deleting a particular file in specified period of time automatically in c#

      the quieter u become more u hear

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      In my knowledge there is not any Propery or method for delete the file automatically. But u can develop application or service for doing this operation.

      If you can think then I Can.

      1 Reply Last reply
      0
      • L lawrenceinba

        hi; is there any coding for deleting a particular file in specified period of time automatically in c#

        the quieter u become more u hear

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        Use a timer to execute the file delete code periodically.

        Me, I'm dishonest. And a dishonest man you can always trust to be dishonest.
        Honestly. It's the honest ones you want to watch out for...

        modified on Saturday, March 13, 2010 4:24 AM

        L 1 Reply Last reply
        0
        • L lawrenceinba

          hi; is there any coding for deleting a particular file in specified period of time automatically in c#

          the quieter u become more u hear

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          lawrenceinba wrote:

          is there any coding for deleting a particular file in specified period of time automatically in c#

          If you mean "is there a method to delete a file at a specific time in c#" then no - you have to write it yourself. But it isn't complex: 1) Create a Timer, give it a sensible interval of 1 minute, or 1 second - depends on how accurate you have to be with the delete time. Create a handler for the Tick event, and start the timer. 2) In the tick event, check if it is time to delete the file, and if so, does it exist. Use the File.Delete method to get rid of the file. You may want this as a service rather than a Windows Forms app, but that is up to you.

          You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • A Abhinav S

            Use a timer to execute the file delete code periodically.

            Me, I'm dishonest. And a dishonest man you can always trust to be dishonest.
            Honestly. It's the honest ones you want to watch out for...

            modified on Saturday, March 13, 2010 4:24 AM

            L Offline
            L Offline
            lawrenceinba
            wrote on last edited by
            #5

            can u explain me further more. else send me any examples for that

            the quieter u become more u hear

            A 1 Reply Last reply
            0
            • L lawrenceinba

              can u explain me further more. else send me any examples for that

              the quieter u become more u hear

              A Offline
              A Offline
              Abhinav S
              wrote on last edited by
              #6

              You can delete a file using the File.Delete() method as shown here[^]. This can be done periodically by using a Timer class. See here[^].

              Me, I'm dishonest. And a dishonest man you can always trust to be dishonest.
              Honestly. It's the honest ones you want to watch out for...

              1 Reply Last reply
              0
              • L lawrenceinba

                hi; is there any coding for deleting a particular file in specified period of time automatically in c#

                the quieter u become more u hear

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #7

                Only after you write it.

                .45 ACP - because shooting twice is just silly
                -----
                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                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