VS 2010 installer project and ApplicationData folder


I have VS 2010 installer project.  In the File System view I added a SpecialFolder - User's Application Data folder (ApplicationData) then I create a folder (FolderA) underneath it then I add a file into that folder.  The file has that squidgy line like when you have spelling error in MS Office Word.  The project builds and installs OK.

Now when I install the app FolderA is in C:\Users\<username>\AppData\Roaming and the file is in there.  I have this code accessing FolderA

private static readonly string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\FolderA\";

This however returns C:\Users\<username>\AppData\Local\FolderA

What is this confusion of Local and Roaming????

This always worked for me (on XP, Vista) but I never created installers in VS 2010 - I used Installshield before. I am on Windows 7 now.  Not sure if the problem is the OS version though

LVL 12
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dennis AriesCEO @ Arkro ITCommented:
The problem is wether the user has a roaming profile or not (e.g. user is AD-user). If so, the default appdata-folder is the romaing-folder. Best option is to check both pathsa to accomodate all kinds of users.
gbzhhuAuthor Commented:
Ok.  but is this a Windows 7 specific as I have been an AD user for many years and didn't see this issue with Vista and VS2005 projects.

If user is roaming then both installation code and .NET framework code should return the same folder - either Roaming or Local.  It seems in my scenario they are not.  Which one is right and which is wrong?
Dennis AriesCEO @ Arkro ITCommented:
AppDataFolder always points to the Roaming folder. LocalAppData is not available in your setup-project.
So in order to make the whole thing work, use the romaing appData in your application too.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

gbzhhuAuthor Commented:

Thank you.  I have used AppDataFolder for my program and VS 2010 installation.  The link you pointed to me shows that LocalAppDataFolder is available but i guess VS 2010 is not allowing us to access it.  MS must make its mind up where these folders point to.  We can't keep changing our code everytime they have a new OS.

<< MS must make its mind up where these folders point to >>
See header file Knownfolders.h =)
There are many locations missing with the GetSpecialFolder enumeration built in but for Windows Vista and later check KNOWNFOLDERID
gbzhhuAuthor Commented:
Thanks for that egl1044

Anyone know why the installation project of Visual Studio cannot allow us to choose either AppData or LocalAppData folder.  Is it doing something under the covers depending on what OS version we are using
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.