Artie Sluka

My toolbar (as referenced in my other posts) has a "Login" link on it, that dynamically changes to "Logout" if my user is currently logged into the website the toolbar is tied to. This code works fine in 9x, 2k and XP:

string currentUser = System.Environment.GetEnvironmentVariable("USERPROFILE");

string[] cookieFiles = System.IO.Directory.GetFiles(currentUser + \\Cookies, "*" + myHost + "*");

However, in my Vista Ultimate beta this code explodes saying, "Access is denied." On further investigation, there are no cookies in this folder.

A different post suggested they were in User\AppData\Roaming\Microsoft\Windows\Cookies, but I can't seem to find them there either.

Is there a "correct" way to programmatically read the cookies in Vista using .NET Furthermore, is there a better way to do it in pre-Vista operating systems than the way I have listed above




Re: Internet Explorer Extension Development Programmatically reading Cookies on Windows Vista using .NET?

Sharath Udupa - MSFT

You are hard coding the Cookies folder, that is not a recommended way to do it. In Win32 you can use SHGetFolderPath/SHGetKnownFolder, in .NET use Environment.GetFolderPath (http://msdn2.microsoft.com/en-us/library/system.environment.getfolderpath.aspx) to get Environment.SpecialFolder.Cookies (http://msdn2.microsoft.com/en-us/library/system.environment.specialfolder.aspx).

HTH
Sharath





Re: Internet Explorer Extension Development Programmatically reading Cookies on Windows Vista using .NET?

Artie Sluka

Been out this week, but will give that a try once I get back to work after the first. Sounds like what I was after though =]