Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey, say if you didn't know where the user's my documents folder was, I know there's a way of coding the folder like &My Documents% or something. What is the correct syntax, and how is it used?

 

I know there's one for system32 too. Any ideas?

 

Thanks!

Chaos is merely logic beyond human comprehension
  • *Experts*
Posted

Try:

string s = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
string s2 = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string s3 = Environment.SystemDirectory;

 

If Environment.SystemDirectory isn't what you want, try another SpecialFolder enum value.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

The best way to get the path to the mydocuments folder in .net is to use the Environment.GetFolderPath function in the framework. There are also several other very useful folders this function gives you access to.

 

For Example:

 

Dim MyDocumentsPath as string = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)

 

 

Side note:

The % symbol is used to identify enviroment variables. For instance on my pc %Temp% brings up my Temporary folder. In XP you can determine which enviroment variables are set by going to System Properties, Advanced tab, and clicking the Enviroment Variables button. The problem with using enviroment variables (at least in my organization) is that the system admins tend to delete them or rename them every so often and without warning.

  • *Experts*
Posted
is there anything you DON'T know?

Lots and lots of things! The big question right now: when will half life 2 *really* come out?

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...