| | |
c# nse File.Delete cannot delete "Temporary Internet Files" files,help me
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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: 3
Reputation:
Solved Threads: 0
1
#5 34 Days Ago
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 |
.net access algorithm array asp.net bitmap box broadcast c# check checkbox client combobox communication control conversion csharp database datagrid datagridview dataset datetime dbconnection decryption degrees design developer draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net hospitalmanagementsystem image input install interface java label libraries list loop marshalbyrefobject math mouseclick movingimage mysql netcfsvcutil.exe numeric operator path photoshop php picturebox pixelinversion platform polynomial post programming properties radians regex remoting richtextbox server sleep socket sql statistics string stringformatting study sun system.servicemodel table tcpclientchannel text textbox thread time timer update usb usercontrol validation visualstudio webbrowser winforms wpf wpfc# xml





