DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   c# nse File.Delete cannot delete "Temporary Internet Files" files,help me (http://www.daniweb.com/forums/thread89007.html)

claverchou Sep 8th, 2007 11:43 pm
c# nse File.Delete cannot delete "Temporary Internet Files" files,help me
 
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

}

claverchou Sep 9th, 2007 4:11 am
RE:c# use File.Delete cannot delete "Temporary Internet Files" files,help me
 
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]

claverchou Sep 9th, 2007 5:39 am
Re: c# use File.Delete cannot delete "Temporary Internet Files" files,help me
 
up

claverchou Sep 9th, 2007 8:51 am
Re: c# nse File.Delete cannot delete "Temporary Internet Files" files,help me
 
help me,thanks

jchandramouli Oct 7th, 2009 8:36 am
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;
}
}
}


All times are GMT -4. The time now is 1:09 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC