Re: How to convert Paths?
try
Code:
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Re: How to convert Paths?
Quote:
Originally Posted by
dannystommen
try
Code:
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
That returns the current user's desktop folder path.
Re: How to convert Paths?
Code:
string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
Re: How to convert Paths?
Quote:
Originally Posted by
sachintha81
That returns the current user's desktop folder path.
It's not against the law to try it yourself. If you had tried some of the other values in the Environment.SpecialFolder enum you would have found it yourself.
Re: How to convert Paths?
Quote:
Originally Posted by
dannystommen
Code:
string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
Thanks Danny.
I'm using .NET 2.0 framework and in it there is no such enum as Environment.SpecialFolder.CommonDesktopDirectory. I hear they've added the feature in .NET 4.0 though.
Re: How to convert Paths?
Quote:
Originally Posted by
foamy
It's not against the law to try it yourself. If you had tried some of the other values in the Environment.SpecialFolder enum you would have found it yourself.
I did try all the enum values before coming here actually. As stated in my previous reply, there is no Environment.SpecialFolder.CommonDesktopDirectory in .NET 2.0 unfortunately. I have to use either the registry key or environment variables instead.
Re: How to convert Paths?
Quote:
Originally Posted by
sachintha81
That returns the current user's desktop folder path.
You could just look at the string returned. If the first folder is documents and settings then replace the user name with all users and if the first folder is users then replace the user name with public.
Re: How to convert Paths?
Quote:
Originally Posted by
DataMiser
You could just look at the string returned. If the first folder is documents and settings then replace the user name with all users and if the first folder is users then replace the user name with public.
Yes I could do that, but apparently there is a function that actually does pretty much the same.
Code:
Environment.ExpandEnvironmentVariables()
For example, if I use the following in Vista,
Code:
Environment.ExpandEnvironmentVariables(@"%PUBLIC%\Desktop")
then it returns;
"C:\Users\Public\Desktop"
And actually when I retrieve the reg key .NET does that for me.