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);
}
}
} }
}
}
################################################## ############################