please just answer the question otherways do not respond to this question.
let me start again. How do I use this class, which extends the internal E
Edit: if you've inherited the code you've shown us and need to use it for some reason (instead of the built-in .NET method that appears to do the same thing), you should be able to use it like this:
string path = EnvironmentFolders.GetPath(EnvironmentFolders.SpecialFolders.Fonts);
Having said that, the Environment
class has a public method that does nearly the same thing, GetFolderPath:
string path = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
The reflected code in .NET looks exactly like the code in your class, except it adds two things: it verifies that the parameter value is defined in the enumeration (since you can pass any integer to the method) and it demands that the caller has path discovery permission (a new FileIOPermission
). Is it that last requirement you're trying to work around?
Both methods are static, meaning you access them through the type that contains them, not an instance of that type:
// Like this
EnvironmentFolders.GetPath(...);
// Not this
EnvironmentFolders folders = new EnvironmentFolders();
folders.GetPath(...);
See the .NET documentation about Static Classes and Static Class Members for more information.
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
Something like this added to the click event of your button.
String path = EnvironmentFolders.GetPath(EnvironmentFolders.SpecialFolder.Favorites)
//do something with the path.
You need more info??
ADDED ON EDIT: Comments are right the method is static this way should work (at least, it worked when I try it on a console app).