| | |
c# nse File.Delete cannot delete "Temporary Internet Files" files,help me
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2007
Posts: 4
Reputation:
Solved Threads: 0
CODE
Get "Temporary Internet Files" directory and files)
const int cookies = 32;
Shell32.Folder objFolder;
Shell32.FolderItems objFolderItems;
Shell32.ShellClass objShell;
string strFolderpath = System.IO.Path.GetTempPath().Substring(0, System.IO.Path.GetTempPath().Length - 1) + "orary Internet Files\\";
objShell = new Shell32.ShellClass();
objFolder = objShell.NameSpace(cookies);
objFolderItems = objFolder.Items();
foreach (Shell32.FolderItem objFolderItem in objFolderItems)
{
//MessageBox.Show(strFolderpath+objFolderItem.Path.ToString());
string strDeleteFile = strFolderpath + objFolderItem.Path.ToString();
File.Delete(strDeleteFile);//delete cannot
}
Get "Temporary Internet Files" directory and files) const int cookies = 32;
Shell32.Folder objFolder;
Shell32.FolderItems objFolderItems;
Shell32.ShellClass objShell;
string strFolderpath = System.IO.Path.GetTempPath().Substring(0, System.IO.Path.GetTempPath().Length - 1) + "orary Internet Files\\";
objShell = new Shell32.ShellClass();
objFolder = objShell.NameSpace(cookies);
objFolderItems = objFolder.Items();
foreach (Shell32.FolderItem objFolderItem in objFolderItems)
{
//MessageBox.Show(strFolderpath+objFolderItem.Path.ToString());
string strDeleteFile = strFolderpath + objFolderItem.Path.ToString();
File.Delete(strDeleteFile);//delete cannot
}
•
•
Join Date: Sep 2007
Posts: 4
Reputation:
Solved Threads: 0
CODE
Get "Temporary Internet Files" directory and files)
const int cookies = 32;
Shell32.Folder objFolder;
Shell32.FolderItems objFolderItems;
Shell32.ShellClass objShell;
string strFolderpath = System.IO.Path.GetTempPath().Substring(0, System.IO.Path.GetTempPath().Length - 1) + "orary Internet Files\\";
objShell = new Shell32.ShellClass();
objFolder = objShell.NameSpace(cookies);
objFolderItems = objFolder.Items();
foreach (Shell32.FolderItem objFolderItem in objFolderItems)
{
//MessageBox.Show(strFolderpath+objFolderItem.Path.ToString());
string strDeleteFile = strFolderpath + objFolderItem.Path.ToString();
File.Delete(strDeleteFile);//delete cannot
}[/QUOTE]
Get "Temporary Internet Files" directory and files) const int cookies = 32;
Shell32.Folder objFolder;
Shell32.FolderItems objFolderItems;
Shell32.ShellClass objShell;
string strFolderpath = System.IO.Path.GetTempPath().Substring(0, System.IO.Path.GetTempPath().Length - 1) + "orary Internet Files\\";
objShell = new Shell32.ShellClass();
objFolder = objShell.NameSpace(cookies);
objFolderItems = objFolder.Items();
foreach (Shell32.FolderItem objFolderItem in objFolderItems)
{
//MessageBox.Show(strFolderpath+objFolderItem.Path.ToString());
string strDeleteFile = strFolderpath + objFolderItem.Path.ToString();
File.Delete(strDeleteFile);//delete cannot
}[/QUOTE]
•
•
Join Date: Dec 2008
Posts: 4
Reputation:
Solved Threads: 0
1
#5 Oct 7th, 2009
private static void ClearCache(string fileName,string fileType)
{
// fileName = * to delete all files with sp.ext
// fileType = * to delete with all ext
String[] files = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache),
fileName + "."+ fileType + ", System.IO.SearchOption.AllDirectories);
foreach (String filePath in files)
{
try
{
System.IO.FileInfo f = new System.IO.FileInfo(filePath);
f.Delete();
}
catch (System.Security.SecurityException se)
{
continue;
}
catch (UnauthorizedAccessException uae)
{
continue;
}
catch (System.IO.IOException ie)
{
continue;
}
}
}
{
// fileName = * to delete all files with sp.ext
// fileType = * to delete with all ext
String[] files = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache),
fileName + "."+ fileType + ", System.IO.SearchOption.AllDirectories);
foreach (String filePath in files)
{
try
{
System.IO.FileInfo f = new System.IO.FileInfo(filePath);
f.Delete();
}
catch (System.Security.SecurityException se)
{
continue;
}
catch (UnauthorizedAccessException uae)
{
continue;
}
catch (System.IO.IOException ie)
{
continue;
}
}
}
![]() |
Similar Threads
- Temporary Internet files?? (Windows NT / 2000 / XP)
- Temporary Internet Files (Windows NT / 2000 / XP)
- Access to "Temporary Internet Files" folder (Windows 95 / 98 / Me)
- how to delete ALL temp internet files, etc. (Windows NT / 2000 / XP)
Other Threads in the C# Forum
- Previous Thread: Deleting File Through C# Program.
- Next Thread: sending mail
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





