locked
Delete Prefetch Folder Contents RRS feed

  • Question

  • I want to be able to delete the windows prefetch folder. However i don't know what's the right word to use so that the system finds automatically the right folder since not everybody installs windows on drive C:. i think it's %systemroot% but i'm getting an error. So please, enlighten me. Here's my code.

    Dim file As String
    For Each file In System.IO.Directory.GetFiles("%systemroot%\prefetch")
    System.IO.File.Delete(file)
    Next file
    Sunday, February 11, 2007 1:36 PM

Answers

  • Use:

    Environment.GetEnvironmentVariable("windir")

    Monday, February 12, 2007 1:32 AM

All replies

  • try this:

    Dim file As String

    Dim SysFolder As String = Environment.SystemDirectory & "\prefetch"

    For Each file In System.IO.Directory.GetFiles(SysFolder)

    System.IO.File.Delete(file)

    Next file

     

    What error are you getting?

    Sunday, February 11, 2007 3:12 PM
  • that the directory didn't exist. Thanks a lot!
    Sunday, February 11, 2007 4:27 PM
  • The Prefetch folder isn't located in the system 32 directory, it's located in the windows directory.
    Sunday, February 11, 2007 5:34 PM
  • Use:

    Environment.GetEnvironmentVariable("windir")

    Monday, February 12, 2007 1:32 AM