[VB.net-APP] - Delete Cache

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zubair1
    New Member
    • Sep 2008
    • 79

    [VB.net-APP] - Delete Cache

    Hello,

    Could some one help me on a problem..

    I am trying to delete all the cache Internet Explorer has..

    but theres a file in the cache folder called Index.dat which it doesn't let me delete - i have browsed around for a while but couldn't find any solution.

    I got an idea from a blog writter - saying that i could do it by marking the file for deletion ... :s but i dont know how do i do that :(

    So it gets deleted the next time the computer is rebooted

    please would really appreciate any assistance :)

    Regards
  • zubair1
    New Member
    • Sep 2008
    • 79

    #2
    bump :(

    eXperts - please help :(

    Comment

    • MrMancunian
      Recognized Expert Contributor
      • Jul 2008
      • 569

      #3
      Try to find out which process uses the index.dat and then kill that process...Then, try again...

      And you really have to be more patient with bumping posts...You can't expect a reaction in just 7 hours of time...The time you posted was 2 AM GMT :p

      Comment

      • zubair1
        New Member
        • Sep 2008
        • 79

        #4
        Originally posted by MrMancunian
        Try to find out which process uses the index.dat and then kill that process...Then, try again...

        And you really have to be more patient with bumping posts...You can't expect a reaction in just 7 hours of time...The time you posted was 2 AM GMT :p
        Thanks MrMancunian :D

        yeah... but i just couldn't wait :(

        i've been looking for a solution for this for over a week now but none yet :(

        i joined Bytes hoping i could resolve my problems here since it looks like an active community with skilled experts and all :) i usually dont join Forums/communities =P :D

        Ever since i posted the question here i've been on a lookout for a solution virtually everywhere on the internet :( i found one which was in C++ :( and VB.2003 :( so it wasn't for me i did email the author if he code port it out for me in VB.net alittle or atleast tell me how to do it in VB.net - but that was just 10 mins ago so i haven't received any response yet :)

        Though his post was mention stuff you said like about the processes -

        There are TWO process which uses the Index.dat files first the explorer.exe and second iexplore.exe.

        I was thinking - if i close both of these processes wouldn't the user be able to tell that i'm doing something like this or might scare him :o (just wondering)

        Does anybody has a better solution?
        I have heard of another one myself :D Its to mark index.dat for deletion - so that the next time the windows reboot it will be deleted but how do i go about doing that its completely out my mind :( i'm just a newbie here :( been only a week since i got started with VB.net :( (maybe less).

        could some one provide some code to help me get started here :)
        i dont have money :( but i can say Thank You =D

        Regards,

        Comment

        • zubair1
          New Member
          • Sep 2008
          • 79

          #5
          [bumper] - :(

          any help plz :(

          Comment

          • balabaster
            Recognized Expert Contributor
            • Mar 2007
            • 798

            #6
            Originally posted by zubair1
            [bumper] - :(

            any help plz :(
            I found this that may be helpful:

            Code:
            class Program
            {
            	[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
            	public static extern bool MoveFileEx(string
            		lpExistingFileName, string lpNewFileName, int dwFlags);
            
            	public const int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4;
            
            	public static void DeleteOnReboot(string filename)
            	{
            		if (!MoveFileEx(filename, null, MOVEFILE_DELAY_UNTIL_REBOOT))
            			System.Windows.Forms.MessageBox.Show("Failed");
            	}
            
            	static void Main(string[] args)
            	{
            		DeleteOnReboot(@"C:\test.txt");
            	}
            }
            You can use it to mark a file for deletion on reboot. That way it'll be deleted by the Windows subsystems as it comes back up. Alas, I couldn't find anything in the .NET Framework that does the same thing...

            Comment

            • zubair1
              New Member
              • Sep 2008
              • 79

              #7
              WOW

              Thanks alot ben :)

              Looks pretty awesome :)

              Is that for Visual C++ :o :( i do have it installed but havent used it yet :(

              i was wondering if i make this code into c++ and make a small application
              is there any possible way i could call that c++ app to mark these files for deletion

              or could you provide any better way to call this function from my VB.net program sir :(

              I'm lost on what to do with this code :(

              Please advise :(

              Thank you
              Regards

              Comment

              • balabaster
                Recognized Expert Contributor
                • Mar 2007
                • 798

                #8
                Originally posted by zubair1
                WOW

                Thanks alot ben :)

                Looks pretty awesome :)

                Is that for Visual C++ :o :( i do have it installed but havent used it yet :(

                i was wondering if i make this code into c++ and make a small application
                is there any possible way i could call that c++ app to mark these files for deletion

                or could you provide any better way to call this function from my VB.net program sir :(

                I'm lost on what to do with this code :(

                Please advise :(

                Thank you
                Regards
                You could just dump it into a C# to VB converter such as the one found at labs.developerf usion.co.uk... I took the liberty of doing it for you:

                Code:
                Class Program 
                    <DllImport("kernel32.dll", CharSet := CharSet.Unicode)> _ 
                    Public Shared Function MoveFileEx(ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Integer) As Boolean 
                    End Function 
                    
                    Public Const MOVEFILE_DELAY_UNTIL_REBOOT As Integer = 4 
                    
                    Public Shared Sub DeleteOnReboot(ByVal filename As String) 
                        If Not MoveFileEx(filename, Nothing, MOVEFILE_DELAY_UNTIL_REBOOT) Then 
                            System.Windows.Forms.MessageBox.Show("Failed") 
                        End If 
                    End Sub 
                    
                    Private Shared Sub Main(ByVal args As String()) 
                        DeleteOnReboot("C:\test.txt") 
                    End Sub 
                End Class

                Comment

                • zubair1
                  New Member
                  • Sep 2008
                  • 79

                  #9
                  Hello

                  Thank you so much sir :)

                  really appreicate your help :)

                  i tried copy/pasting the code into my vb.net

                  but its giving an error - Type 'DllImport' not defined.

                  Below is the code i am pasting
                  Code:
                      <DllImport("kernel32.dll", CharSet := CharSet.Unicode)> _ 
                      Public Shared Function MoveFileEx(ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Integer) As Boolean 
                      End Function 
                      
                      Public Const MOVEFILE_DELAY_UNTIL_REBOOT As Integer = 4 
                      
                      Public Shared Sub DeleteOnReboot(ByVal filename As String) 
                          If Not MoveFileEx(filename, Nothing, MOVEFILE_DELAY_UNTIL_REBOOT) Then 
                              System.Windows.Forms.MessageBox.Show("Failed") 
                          End If 
                      End Sub 
                      
                      Private Shared Sub Main(ByVal args As String()) 
                          DeleteOnReboot("C:\test.txt") 
                  End Class

                  Comment

                  • zubair1
                    New Member
                    • Sep 2008
                    • 79

                    #10
                    Hi,

                    just a follow-up to my last post

                    I think i found the solution by doing a small search :)

                    Code:
                    Imports System.Runtime.InteropServices
                    I had to add this namespace into the code and it wasn't showing errors after that.

                    :)

                    Comment

                    • zubair1
                      New Member
                      • Sep 2008
                      • 79

                      #11
                      one small help please :(

                      how do i use this new function

                      it is loading now without any errors

                      but i am not sure which function i should call to make the job successful.

                      Comment

                      • balabaster
                        Recognized Expert Contributor
                        • Mar 2007
                        • 798

                        #12
                        Originally posted by zubair1
                        one small help please :(

                        how do i use this new function

                        it is loading now without any errors

                        but i am not sure which function i should call to make the job successful.
                        Code:
                        DeleteOnReboot("C:\MyFile.txt")

                        Comment

                        • zubair1
                          New Member
                          • Sep 2008
                          • 79

                          #13
                          Originally posted by balabaster
                          Code:
                          DeleteOnReboot("C:\MyFile.txt")
                          yup, got that - Thanks alot Mr.Expert =D

                          The code is working smoothly - the code you posted i found earlier and had it saved in a separate text-file but it was in C language :( but you also showed how to convert it which i never new was possible :D

                          Thank you so much for the awesome help sir :)

                          Comment

                          Working...