Reapz Posted May 20, 2003 Posted May 20, 2003 I've used treeviews before and have managed to get my head around them ok but this is the first time I have used one to list drives and folders like Windows Explorer (Dont need to worry about files btw). Anyway, I've encountered a couple of problems. 1) I have had to eliminate drives that 'Aren't ready'. ie: empty floppy and optical drives otherwise trying to expand generates and error. I did this by simply ommitting drives that had no label. What I would like is to be able to handle empty drives properly like explorer does. 2) Regardless of the folder settings in Windows Explorer GetDirectories picks up system folders and adds them to the treeview and trying to expand these generates an 'Access denied' error. Is it possible to make my App' adhere to the windows folder settings? Cheers! Quote I'm getting the hang of this now... No really I am!
*Gurus* divil Posted May 21, 2003 *Gurus* Posted May 21, 2003 1) You populate your treeview with the drives, not the folders within them. You should only attempt to get the list of folders within when the user actually clicks on them, like explorer does. 2) You need to examine the attributes of each folder as you process it, and simply don't show ones with the System or Hidden attributes. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Reapz Posted May 21, 2003 Author Posted May 21, 2003 (edited) Ok I thought I had this working doing what you said but it only seems to work with files. The only attribute that is returned when I do folder.Attributes is 'Directory'. It doesn't mention whether it is a 'System' or 'Hidden' folder. So pulling out system and hidden files is simple but the system folders remain in the treeview. Edited May 21, 2003 by Reapz Quote I'm getting the hang of this now... No really I am!
*Gurus* divil Posted May 22, 2003 *Gurus* Posted May 22, 2003 di = new System.IO.DirectoryInfo(path); if ((di.Attributes & System.IO.FileAttributes.System) != System.IO.FileAttributes.System) System.Diagnostics.Debug.WriteLine(path); Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.