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 9021107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:10:37+00:00 2026-06-16T05:10:37+00:00

I have created a .msi by using VS2008 setup project. My application frequently writes

  • 0

I have created a .msi by using VS2008 setup project. My application frequently writes some value in a .txt file in the application directory (C:\Program Files\MyApp\MyFile.txt). After insalling it in Win7, it raises an exception “Access to the path …. is denied.”

But whenever I run it as administrator, no such exception occurs. Here is my sscce

string FilePath=Application.StartupPath + @"\AppSettings\CurrentUserName.inf";
using (StreamWriter writer=new StreamWriter(FilePath,false))
{
    writer.Write(txtLoginName.Text.Trim());
}
MainForm.ProcessLogIn();
this.DialogResult = DialogResult.OK;

I don’t know how to solve this problem. Any suggestion?

  • 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-16T05:10:39+00:00Added an answer on June 16, 2026 at 5:10 am

    The only way to solve this problem is to not write to that folder. You are not allowed to write to that folder by convention, unfortunately, older versions of Windows did not hold you to this.

    Instead, you can use Environment.SpecialFolder to help you find where you need to go:

    // your application data for just that User running the app
    var perUserAppData = Environment.GetFolderPath(
        Environment.SpecialFolder.ApplicationData);
    
    // your application data for ALL users running the app
    var allUsersAppData = Environment.GetFolderPath(
        Environment.SpecialFolder.CommonApplicationData);
    
    // better!
    var path = Path.Combine(perUserAppData, @"MyApp\MyFile.txt");
    

    Basically, Windows 7 is telling you that you’re going to have to stop driving on the sidewalks and use the street as was intended.

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

Sidebar

Related Questions

I have a console application and I want to deploy/share it using some msi/setup.exe
I have an .MSI file created using VS2008. This .MSI is composed of a
I have a MSI created using InstallShield. I do not have the InstallShield project.
I have created a setup project using Visual Studio 2008 . When installing on
I recently created a Windows application project using C#. I have completed all the
I am using WIX for my application's setup project, I have to install device
I created a MSI installer by using Visual Studio 2008. I have some temp
I have created an MSI package (Using InstallShield - IS) that installs my application
I have a .msi file created by a program called MSICREATE and doctored using
I have created an android application that calls (using kSOAP library) a SOAP based

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.