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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:47:12+00:00 2026-05-26T13:47:12+00:00

I want to use a data file and read it from a WinForms app.

  • 0

I want to use a data file and read it from a WinForms app. If I use methods like Application.ExecutablePath or Application.StartupPath they reference the folder ..\bin\debug, which is different in non VS hosted app. I want to use a folder off the root folder and get a reference to it regardless if I am in debug mode or not, ie, it always works right.

What’s a good way to do it? I prefer not to use an embedded resource file and not use hard coded full paths. It needs to be a relative path off the app’s root folder.

Something like ~/App_Data in ASP.NET

Addition:

I want to use a relative path off “some path”. “Some path” is what I am seeking, regardless if I am in VS in debug mode, non debug mode or if the app is deployed. Just like ASP.NET’s “~”. It doesn’t care where the site is or if you’re in VS. I don’t want to create a folder under ‘debug’ folder. It’s the same folder no matter what. “Some folder” is also off the VS’s app folder because the app will be zipped to be used without deployment or publishing.

  • 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-26T13:47:13+00:00Added an answer on May 26, 2026 at 1:47 pm

    My solution. Go up two folder levels and then to data folder:

        string appPath = Path.GetDirectoryName(Application.ExecutablePath);
    
        System.IO.DirectoryInfo directoryInfo = System.IO.Directory.GetParent(appPath);
        System.IO.DirectoryInfo directoryInfo2 = System.IO.Directory.GetParent(directoryInfo.FullName);
    
        string path = directoryInfo2.FullName + @"\data";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application i have to read data from a CSV file. I want
i want simultaneously read and write data into file. Can i use StreamReader and
I want to use java.nio.channels.FileChannel to read from a file, but I want to
Hi I want read from a hung text file data directly to a string
I have a CLI script and want it to read data from a file.
I'm using System.Data.Linq.DataContext file for accessing a mdf Database I want to use the
i want use some data from a website with web service. i have a
I want to use geoJSON-formatted Data in my iPhone app. THere is a JSON
If we want to use thread specific data in a multithreaded application, how to
I have an application that imports data read from text files from a directory

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.