PDA

View Full Version : How to group pathes according to...


mangomel
06-19-2007, 06:14 AM
My apps deletes some files from _ProgramfilesFolder, _WindowsFolder, Documents and settings folder etc. Each folders may be on a different drives. I want to know how many space did deleting free up. So I should get free space (Drive.GetFreeSpace) before and after deleting of each drive of this folders and subtract first result from the second. Now I would get amount (in mb) of deleted files on each drive. Then I should add this numbers to get size of all deleted files.
But, If the path to windows folder and program files folder has the same drive letter, then the overall size would be wrong because I add two (or more) result from the same drive together!

So first I should get drive letters from all pathes and group it according to these letters and then get free space before and after deleting and finally, add result together.
But how to group it? Any similar ideas? Any other ideas? Please help!

RizlaUK
06-19-2007, 06:27 AM
you can use String.SplitPath to get the drive letter


sPath = String.SplitPath("C:\\Program Files\\My Product\\MyFile.ext");
nSpace = Drive.GetFreeSpace(sPath.Drive);

mangomel
06-19-2007, 03:50 PM
Yes, I know. Then I would get f.e.:
C, D, C, E, D, C, C from each path. But how to get free space only once per letter - from: C, D, E ? If I get free space from the same drive twice or more, the result will be wrong (multiplicated).

mangomel
06-21-2007, 03:23 PM
Nobody knows?

Tek
06-21-2007, 03:54 PM
Use a table to store the paths that have been checked, or even just the drive letters and if they have already been searched before then skip it and move onto the next one.

Either that or get the free space before deletion, then once you have deleted the files you want, get the free space again and get the difference to find out how much space was freed.