Special Directories

Use this board to post your code snippets - tips and tricks
4 posts Page 1 of 1
Contributors
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Special Directories
CodenStuff
Hello,

Sometimes when designing an application you may want to access special folders on the users computer like "Desktop or My Documents" folders but because everyone has a different computer/user name it would be hard to know the location of the folder. VB includes generic code to locate these folders on any machine so for example if you needed to know the location of the users "My Documents" folder you can use this code to return its location:
Code: Select all
My.Computer.FileSystem.SpecialDirectories.MyDocuments
And the same for other folders:
Code: Select all
My.Computer.FileSystem.SpecialDirectories.Desktop
My.Computer.FileSystem.SpecialDirectories.MyMusic
My.Computer.FileSystem.SpecialDirectories.MyPictures
My.Computer.FileSystem.SpecialDirectories.ProgramFiles
My.Computer.FileSystem.SpecialDirectories.Temp
Although those codes are short and simple they can make a big difference in your applications. For example I would say that most windows users keep there images in the default "My Pictures" folder so if you were making an image viewer/editor you could point it immediately to the My Pictures folder and load all the users pictures into your application. It saves the user hassle from having to manually navigate to the folder.

Happy coding cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Special Directories
zachman61
could this locate the "app data/local" or "local/application data" for gaming mods locations
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
Insignia
VIP-Member
VIP-Member
Posts: 238
Joined: Thu Feb 11, 2010 5:15 pm

Re: Special Directories
Insignia
Here zach :)

My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData
My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData
User avatar
RonaldHarvey
Top Poster
Top Poster
Posts: 113
Joined: Tue Apr 05, 2011 2:32 pm

Re: Special Directories
RonaldHarvey
Thanks CodenStuff this will really save us time for our apps. cooll;
4 posts Page 1 of 1
Return to “Quick Snips”