Exclude Dir From path

419 views Asked by At

I want to Get all dirs from my drive Excluding "System Volume Information" The problem is i am sending args to another console application for compressing though. and i'd have to send only single path. how to do that?

E.g. command line of qpress.exe

qpress.exe -dvf ArchiveName.qp "SourceDir"
qpress.exe -dvf D:\Archive.qp G:\

i want to Exclude "System Volume Information" Folder from being Included in Archive

1

There are 1 answers

1
Davide Piras On

If you want to do it right and you have to send to your console application all directory names in your disk drive, let's say at the first/root level, you should not only hard code or exclude the folder "System Volume Information" because you cannot be sure there are not other folders for which you have no rights to read/open...

I think a good approach is to check every single folder name for read permissions ( or whatever other permission you might need to have on such folder in the console application you pass the foldername to ).

This is in general a good approach, to always verify if you can do a certain thing, for example before deleting a file, check if you can actually delete it. Or if you prefer, you could then catch the exception afterwards, but probably your external console application would crash so better check rights before calling it with a specific folder name.