4 Replies - 368 Views - Last Post: 30 November 2019 - 03:31 PM Rate Topic: -----

#1 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 797
  • Joined: 15-December 14

Delete Mozilla temporary files isn't working why?

Posted 26 November 2019 - 01:11 PM

I wanted to make a program to delete browser, temporary Internet files, cookies from different Internet browsers. I've been able to get the code to work on IE, but for some reason I cannot get it to work on Mozilla. I've found on other programming forums how to do it, but I don't want to be a script kitty and I know I would benefit from doing it myself.
what I did was look online how to remove files and directories using C# and then modified it to do it to temporary Internet files, cookies for Mozilla.

What am I doing wrong?

This is the code.
using System;
using System.ComponentModel;
using System.Threading;
using System.Diagnostics;
//
using System.Collections.Generic;
using System.IO;
using System.Text;


namespace Garbage_sweeper
{
    class Program
    {
        static void Main(string[] args)
        { 
            Console.Write("Which browser do you want to delete ");
            Console.WriteLine("cookies, browser history and cache");
            int choice;
            string[] browsers = { "Internet Explorer","Mozilla Firefox", "Microsoft Edge", "Clear everything",
            "Chrome"};
            while (true)
            {
                for (int x = 0; x < 5; x++)
                {
                    Console.Write(x + 1 + ".");
                    Console.WriteLine(browsers[x]);
                }
                choice = Convert.ToInt32(Console.ReadLine());
                if (choice == 1)
                    IE();
                else if (choice == 2)
                    Mozilla();
            }
        }
        static void IE()//Internet Explorer
        {
            Console.WriteLine("Deleting browser history");
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 1");
            Thread.Sleep(7000);
            Console.WriteLine("Deleting cookies");
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 2");
            Thread.Sleep(7000);
            Console.WriteLine("Deleting Temporary Internet Files");
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 8");
            Thread.Sleep(7000);
            Console.WriteLine("Deleting form data");
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 16");
            Thread.Sleep(7000);
            Console.WriteLine("\n");
        }
        static void Mozilla()//Mozilla Fire Fox
        {
            
            const string FireFoxPath = @"C:Users\albert\AppData\Roaming\Mozilla\Firefox\Profiles\";
            //
            List<string> directories = new List<string>();
            List<string> files = new List<string>();

            foreach (string file in files)
            {
                System.IO.File.Delete(file);
            }
            foreach (string directory in directories)
            {
                Directory.Delete(directory);
            }
        }
    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: Delete Mozilla temporary files isn't working why?

#2 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7192
  • View blog
  • Posts: 24,370
  • Joined: 05-May 12

Re: Delete Mozilla temporary files isn't working why?

Posted 26 November 2019 - 01:45 PM

Elaborate on "I cannot get it to work on Mozilla". What error messages are you getting? What behavior are you seeing?

Right now, looking at your lines 52-68 it looks like your lists of files and directories are empty. Perhaps you should call some methods on the Directory or DirectoryInfo classes.
Was This Post Helpful? 0
  • +
  • -

#3 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 797
  • Joined: 15-December 14

Re: Delete Mozilla temporary files isn't working why?

Posted 26 November 2019 - 02:32 PM

Sorry what I meant was it runs and I do not get any error messages. When I check Mozilla for cookies, temporary files, etc. They were not deleted by my program.

Ok, I'll give that a try calling some methods on the Directory and DirectoryInfo class.
Was This Post Helpful? 0
  • +
  • -

#4 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 797
  • Joined: 15-December 14

Re: Delete Mozilla temporary files isn't working why?

Posted 29 November 2019 - 07:40 PM

Thanks for the advice, it works perfectly.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7192
  • View blog
  • Posts: 24,370
  • Joined: 05-May 12

Re: Delete Mozilla temporary files isn't working why?

Posted 30 November 2019 - 03:30 PM

I'm glad you figured it out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1