Results 1 to 5 of 5

Thread: Clearing temp directory question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Clearing temp directory question

    I am creating what could amount to quite a few temp files on a terminal server using the System.IO.Path.GetTempPath. My question is this. Can I trust Windows to clear that directory on a regular basis or do I need to clear it in code?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Clearing temp directory question

    Quote Originally Posted by FastEddie
    I am creating what could amount to quite a few temp files on a terminal server using the System.IO.Path.GetTempPath. My question is this. Can I trust Windows to clear that directory on a regular basis or do I need to clear it in code?
    Windows will never clear the temp folder. How does the OS know when those files are no longer needed? It's every application's responsibility to clear its own temp files.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Re: Clearing temp directory question

    Oh I always thought Windows did periodic clean up in the temp directory. Now I am not sure how I am going to remove the files after use. My problem is that the user can keep open the file long after the application is closed.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Clearing temp directory question

    Maybe ApplicationData would be a better location than Temp then.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Addicted Member
    Join Date
    May 2006
    Posts
    226

    Re: Clearing temp directory question

    JMc,

    Would you mind explaining your answer a little bit more?

    I also have an application that generates files (PDF files in my case) and the user may or may not have the files open when they exit my program.

    What can we do with ApplicationData to enable better control over these files? Then, how (when) do we delete files later?

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width