Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7739755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:36:04+00:00 2026-06-01T08:36:04+00:00

I am using C# with .net 3.5 I am saving my program data in

  • 0

I am using C# with .net 3.5

I am saving my program data in a file under: C:\Program Data\MyProgramName\fileName.xml

After installing and running my application one time I uninstalled it (during uninstallation I’m removing all the files from “program data”)
and then I reinstall the application, and ran it.

The strange thig is that my application started as if the files in program data existed – means, I had old data in my app even though the data file was deleted.

When running:

File.Exists("C:\Program Data\MyProgramName\fileName.xml")

I got “true” even though I knew for sure that the file does not exist.

The thing became stranger when I ran the application as admin and then the file didn’t exist.

After a research, I found out that when running my application with no admin priviliges instead of getting: “C:\Program Data\MyProgramName\fileName.xml” I get “C:\Users\userName\AppData\Local\VirtualStore\ProgramData\MyProgramName\fileName.xml”

and indeed there was a file that existed from the previous installation (that I obviously didn’t delete ,because I didn’t know it existed).

So apparentlly there is some virtual path to the file under program data.

EDIT :

I found out that after deleting the old file in the virtual store, my application is suddenly able to find the correct file. (I didn’t make any changes in the file under Program Data.

My question is:

  1. why is it happen.
  2. How can I prevent it from happening

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:36:06+00:00Added an answer on June 1, 2026 at 8:36 am

    Do you actually have to write to the per-system Program Data folder instead of the per-user Application Data folder(s)?

    You might want to take a look at Environment.GetFolderPath and the following Environment.SpecialFolders:

    • Environment.SpecialFolder.ApplicationData – data folder for application data, synchronized onto domain controller if the user profile is roaming
    • Environment.SpecialFolder.LocalApplicationData – data folder for application data, local and not synchronized (useful for, for instance, caches)

    EDIT:

    Tested on Windows 7 x64, non-administrator user.

    var appData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
    var myFolder = Path.Combine(appData, "MyApp");
    if(!Directory.Exists(myFolder)) Directory.CreateDirectory(myFolder);
    File.WriteAllText(Path.Combine(myFolder, "Test.txt"), "Test.");
    

    This does what is expected, ie. writes into C:\ProgramData\MyApp\Test.txt. As far as I can tell (Administrator mode Command Prompt), there’s no UAC virtualization going on either.

    Double edit:

    I guess what’s happened is that at some point an Administrator user has written the files into your ProgramData folder, and as such, UAC file system virtualization kicks in and redirects the non-administrator writes into the VirtualStore.

    Does your uninstaller run as Administrator? If it does, you might have to check both the VirtualStore path for the user who initiates the uninstall, and the actual file system path for program data to remove. I’m not sure if there’s an official way to do this, though…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET program where i am downloading a file from web using
I'm using CruiseControl.NET to run visual studio test cases after my project builds. In
I am using ASP.NET 2.0 and SQL Server 2005. I am saving a value/string
Using VB.NET, I am trying to create a text file if it doesn't exist
Using .NET (in an SSIS package): I've got an XML string in memory which
I have a forum application using asp.net, c#, sql server and linq to sql.
I am using a text file to have some data there for later purposes.
I am using ASP.NET C# 4.0, my web form consist of input type file
I'm trying to store a file in an SQL Server database and am using ASP.NET
I have a .NET application that makes calls to a native Win32 DLL using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.