Deleting folder "Temporary Internet Files"

Discussion in 'Java' started by Rosa, Mar 23, 2005.

  1. Rosa

    Rosa Guest

    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);
    }
    }
    }
    }
    }
    }
    ##############################################################################
    Rosa, Mar 23, 2005
    #1
    1. Advertising

  2. Rosa

    Rhino Guest

    "Rosa" <> wrote in message
    news:...
    > 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
    Rhino, Mar 23, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rosa
    Replies:
    2
    Views:
    612
  2. Purva
    Replies:
    0
    Views:
    117
    Purva
    Dec 28, 2005
  3. phpninja
    Replies:
    1
    Views:
    148
    Grant Wagner
    Nov 4, 2004
  4. Rosa
    Replies:
    5
    Views:
    214
  5. ammalu

    deleting temporary internet files

    ammalu, Nov 26, 2008, in forum: Javascript
    Replies:
    3
    Views:
    259
    Stevo
    Nov 26, 2008
Loading...

Share This Page