aipet

hi,

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

how to achieve the same in framwork 1.1. Environment does not have SpecialFolder in vs2003 ;-(

thanks



Re: Visual C# General Environment.SpecialFolder.MyDocuments in C#1.1

Peter Ritchie

You'll have to PInvoke SHGetFolderPath with the CSIDL_PERSONAL value

Something like:

Code Snippet
[DllImport("shfolder.dll", CharSet=CharSet.Auto)]
internal static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
    StringBuilder lpszPath = new StringBuilder(260);
const int CSIDL_PERSONAL = 5;
Win32Native.SHGetFolderPath(IntPtr.Zero, CSIDL_PERSONAL, IntPtr.Zero, 0, lpszPath);
string path = lpszPath.ToString();

 






Re: Visual C# General Environment.SpecialFolder.MyDocuments in C#1.1

aipet

thanks Peter for your fast reply. actually it does exist in 1.1, BUT i do not see this specialfolder enum in my solution. what could make it dissapered gosh

i guess this should work too -

string filename = Environment.GetEnvironmentVariable("USERPROFILE");