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

  • Home
  • SEARCH
  • 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 6689057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:28:30+00:00 2026-05-26T05:28:30+00:00

I have Winforms application that must create write to certain configuration file during usage.

  • 0

I have Winforms application that must create write to certain configuration file during usage. Once i use debug mode this file can be create and written to it but once i create Setup Project and actually install the application i cannot access with following exception.

Configuration file is located the same directory as program ( at Program Files )

Code i’m using to read/write is.

public static string[] GetDefaultConfigFile(string path)
{
    string[] res = {};
    if (File.Exists(GetInternalFileName(path)))
    {
        using (StreamReader tr = new StreamReader(GetInternalFileName(path)))
        {
            res = tr.ReadToEnd().Split(';');
        }
    }
    return res;
}

public static void SaveDefaultConfigFile(string fileName, string path)
{
    using (var tw = new StreamWriter(GetInternalFileName(path)))
    {
        tw.Write(fileName);
        tw.Close();
    }
}

private static string GetInternalFileName(string path)
{
    return path + "\\setup.config";
}
  • 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-05-26T05:28:30+00:00Added an answer on May 26, 2026 at 5:28 am

    Maybe the account used to run this code doesn’t have sufficient privileges to write to the specified folder (Program Files). If you are running under Windows 7 or Vista standard users are not authorized to write to this folder. In this case you could use the user specific folder c:\users\username to store configuration settings.

    Also I would simplify:

    public static string[] GetDefaultConfigFile(string path)
    {
        return File.ReadAllText(path).Split(';');
    }
    
    public static void SaveDefaultConfigFile(string fileName, string path)
    {
        File.WriteAllText(path, fileName);
    }
    
    private static string GetInternalFileName(string path)
    {
        return Path.Combine(path, "setup.config");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winforms application that presently ships with a chm file for context-sensitive
I have a winforms application that the users must be able to change the
I have a WinForms application. That application have a rich functionality. It can create
I have a winforms application that normally is at about 2-4% CPU. We are
I have C# winforms application that needs to start an external exe from time
I have a winforms application that is doing the following: on each query: Db
I have an winforms application that was built using MVC. The controller is subscribing
I have a desktop (winforms) application that uses a Firebird database as a data
I have a .net 3.5 WinForms application that runs fine on my machine, but
We have a WinForms application written in C# that uses the AxAcroPDFLib.AxAcroPDF component to

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.