Results 1 to 4 of 4

Thread: Clearing History

  1. #1

    Thread Starter
    Member Chroder's Avatar
    Join Date
    Aug 2003
    Posts
    56

    Clearing History

    I've got a list of history files and a function that loops through and deletes them. Buuut, I always get a "in use" error. Is there any way I can stop this?

    Important parts:

    Code:
    		private void frmMain_Load(object sender, System.EventArgs e)
    		{
    			path = Environment.GetFolderPath(Environment.SpecialFolder.History) + "\\";
    			getList(path);
    			
    		}
    
    		private void getList(string thepath)
    		{
    			DirectoryInfo dir = new DirectoryInfo(thepath);
    			DirectoryInfo[] dirs = dir.GetDirectories();
    			FileInfo[] files = dir.GetFiles();
    			foreach(DirectoryInfo d in dirs)
    			{
    				getList(d.FullName);
    			}
    
    			foreach(FileInfo f in files)
    			{
    				lstHistory.Items.Add(f.FullName);
    			}
    		}
    
    		private void clrHist()
    		{			
    			for(int i = 0; i < lstHistory.Items.Count; i++)
    			{
    				try
    				{
    					File.Delete(lstHistory.Items[i].Text);
    				}
    				catch(IOException e)
    				{
    					MessageBox.Show("Error: \n\n\n" + e.Message);
    				}
    			}
    		}

    TIA

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    You might check and see if a filename.fileExtension.LCK file exists in the directory, which would mean the file is currently in use.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Member Chroder's Avatar
    Join Date
    Aug 2003
    Posts
    56
    If the file is in use, then its impossible to delete/modify correct? Then how does IE clear the history? Am I taking the wrong approch?

    Thanks for you help

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    first of all close all IE windows , then run that code
    \m/\m/

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