|
-
Nov 1st, 2003, 12:32 PM
#1
Thread Starter
Member
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
-
Nov 1st, 2003, 03:13 PM
#2
Frenzied Member
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
-
Nov 1st, 2003, 05:39 PM
#3
Thread Starter
Member
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
-
Nov 3rd, 2003, 08:35 AM
#4
yay gay
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|