Deleting folder "Temporary Internet Files"

R

Rosa

Hi,
I'm trying to clear the TIF on Windows XP programmatically with the
below code.
This code works fine on any folder but the TIF. For some reason the
atEnd() statements always defaults to true and no files are deleted in
the folder.
The peculiarity of this issue is that the files/subfolders cannot be
seen through the windows explorer either. I can only access/delete
them through a command shell.
Any ideas?
Many thanks
Rosa
CODE:
#############################################################################
// This is the root, which we analyse
var sRoot="C:\\Documents and Settings";
var sLocalSettings="\\Local Settings\\"

// Declaration of other variables
var fso, f, fc, fcf, logfile,TIFFolder, s;
s= "";

// Create the FileSystemObject
fso = new ActiveXObject("Scripting.FileSystemObject");

// Navigate to our root
f = fso.GetFolder(sRoot);

// Log-file
logfile = fso.CreateTextFile("c:\\del.log", 1);
logfile.WriteLine("Logging for the script to delete Temporary Internet
Files Folder");
logfile.WriteLine("================================================================");

// Enumerate all Subfolders to fc, by using the SubFolders-method of
FSO
fc = new Enumerator(f.SubFolders);
for (; !fc.atEnd(); fc.moveNext())
{
// store path to the Temporary Internet Files in TIFFolder
TIFFolder = fc.item() + sLocalSettings + "Temporary Internet
Files";

// dont even try to delete in the following Profiles
if ( (fc.item() == (sRoot + "\\All Users")) ||
(fc.item() == (sRoot + "\\Default User")) ||
(fc.item() == (sRoot + "\\LocalService")) ||
(fc.item() == (sRoot + "\\NetworkService")))
{
continue;
}


// Check, if there is a folder Temporary IE Files
if (fso.FolderExists(TIFFolder))
{

// Now we can delete that folder
try
{
fso.DeleteFolder(TIFFolder);
logfile.WriteLine("FOLDER: " + TIFFolder + " has been deleted
successfully");
}
catch(e)
{
logfile.WriteLine("FOLDER: " + TIFFolder + " Could not be deleted.
--- Error: " +e.number+ " Error-description: " + e.description);
fcf = new Enumerator(f.files);
if (fcf.atEnd())//for TIF this is always true
{
logfile.WriteLine("No files in folder.");
}
else
{
for (; !fcf.atEnd(); fcf.moveNext())
{
s = fcf.item();
try
{
s.Delete();
logfile.WriteLine("FILE: " + s + " has been deleted
successfully");
}
catch(e)
{
logfile.WriteLine("FILE: " + s + " Could not be deleted. ---
Error: " +e.number+ " Error-description: " + e.description);
}
}
}
}
}
}
##############################################################################
 
R

Rhino

Rosa said:
Hi,
I'm trying to clear the TIF on Windows XP programmatically with the
below code.
This code works fine on any folder but the TIF. For some reason the
atEnd() statements always defaults to true and no files are deleted in
the folder.
The peculiarity of this issue is that the files/subfolders cannot be
seen through the windows explorer either. I can only access/delete
them through a command shell.
Any ideas?
Many thanks
Rosa
CODE:
############################################################################
#
// This is the root, which we analyse
var sRoot="C:\\Documents and Settings";
var sLocalSettings="\\Local Settings\\"

// Declaration of other variables
var fso, f, fc, fcf, logfile,TIFFolder, s;
s= "";

Although some of your code looks like Java, the bit above isn't so I'm
guessing that this is really a Java program, just something that looks
similar, like C#. I think you'd do better if you posted to a newsgroup for
the language you *are* using, whatever that is.

Rhino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top