fso delete folder

  • Thread starter Thread starter shockley
  • Start date Start date
S

shockley

OK, I just wrote a neat macro to loop through all the subdirectories of a
given folder and delete each subfolder starting with the most distant from
the mother folder and working back.

But as each folder was deleted I noticed that the folder simply disappeared
after a slight pause without the usual Windows progress display and, for
folders with many files, without the lengthy deletion process.

So now, I can just chuck my neat looping/self-calling macro and just say
f.Delete where f is the mother folder fso object.

I would just like to know whether there is any difference for my hard-drive
between the two delete methods (fso vs Windows/manual). And, if there is no
difference, why does Windows do it the long way?

Shockley
 
Shockley,

When you use the DeleteFolder method, you do not move the folder
and its file to the Recycle Bin. The folder and files are gone
forever. When you manually delete a folder through Windows
Explorer, you are copying the files from their original location
to the Recycle Bin, the deleting the original files. It is this
copying that causes the delay in the manual delete process.
Using DeleteFolder deletes the folder and files immediately, with
no copy to the Recycle Bin, and so is much faster.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Chip,

Reconcile this then:

I haven't had my Recycle Bin turned on in years. Also, copying files between
folders on the same drive takes only a moment as, it seems, the files are
only given a new path--not actually re-created as when you are copying to a
different drive.

Regards,
Shockley
 
Yes windows should only be changing the path in the File Allocation
Table (FAT) instead of putting it on the new drive. When windows
deletes it should only be telling that FAT that the memory can be
overwritten (that is why they can find "deleted" files on your hard
drive.) At least that is how I think I remember them working.


Keith
www.kjtfs.com


Chip,

Reconcile this then:

I haven't had my Recycle Bin turned on in years. Also, copying files
between
folders on the same drive takes only a moment as, it seems, the files
are
only given a new path--not actually re-created as when you are
copying to a
different drive.

Regards,
Shockley
 
One more piece to the puzzle:

When deleting files manually and you get the progress screen showing the
files whizzing by, it goes much faster than if you were copying or moving
the files to another drive, which says to me that deleting manually is
different from copying to the Recycle Bin, even if the RB is on a different
drive.

Also, with the fso Folder.Delete method, since it takes only a moment, is
the FAT table updated THAT fast (i.e., to show that the files can be
overwritten?) ?

Shockley


KJTFS said:
Yes windows should only be changing the path in the File Allocation
Table (FAT) instead of putting it on the new drive. When windows
deletes it should only be telling that FAT that the memory can be
overwritten (that is why they can find "deleted" files on your hard
drive.) At least that is how I think I remember them working.


Keith
www.kjtfs.com


Chip,

Reconcile this then:

I haven't had my Recycle Bin turned on in years. Also, copying files
between
folders on the same drive takes only a moment as, it seems, the files
are
only given a new path--not actually re-created as when you are
copying to a
different drive.

Regards,
Shockley

 
Back
Top