Winforms and Console Applications can use Application.UserAppDataPath.
What if I want to build the same path from a dll? How can I do that?
I know that Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) would be the start...
views:
119answers:
2
A:
Well, if you don't have an application object that you can use, you would start out with what you mentioned to get the "ApplicationData" folder path, then append the default folder structure on to that path.
CompanyName/ProductName
is the default additional items
Mitchel Sellers
2009-11-15 07:32:54
A:
You can use Application.UserAppDataPath from a DLL - simply add a reference to the System.Windows.Forms assembly from your DLL project.
However be aware that if your DLL is used in a Windows Service or Server application such as ASP.NET, it may run under an service account that does not have a profile - in this case UserAppDataPath won't exist. This is probably the main reason the Application class is in the System.Windows.Forms namespace.
Joe
2009-11-15 10:21:12