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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:18:38+00:00 2026-06-14T05:18:38+00:00

i made a program that uses a pre-made text file that hold a list

  • 0

i made a program that uses a pre-made text file that hold a list of sites.
now in some computer the program works fine but, in my friend computer it doesn’t.

i check the program on 2 of my windows 7 computers, and 1 xp and i don’t have any errors.
this program was used for some time on XP, now my friend want to install it in his windows 7 computer at home, but the program doesn’t find the file after he install the program.

this is the error he get:

System.IO.FileNotFoundException: file not found 'C:\Users\eli\AppData\Roaming\fourmlinks.txt'.
file name: 'C:\Users\eli\AppData\Roaming\fourmlinks.txt'

the thing is that i ship the this file in main program folder (Application Files), and it still cant find it.

this is the code i use to find the file when the program starts:

sring path = "";
path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\fourmlinks.txt";
            System.OperatingSystem osInfo = System.Environment.OSVersion;
            if (osInfo.Platform == PlatformID.Win32NT)
            {
                if (osInfo.Version.Major == 5 && osInfo.Version.Minor != 0)
                {
                    //running XP
                    //path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\fourmlinks.txt";
                    path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\fourmlinks.txt";
                }
            } 

you can see, that i tried to make sure it will work on windows 7 and, windows xp.

NOTE:
i don’t mind changing the way i work with this file, or even loss this way and try completely different way that will work on the OS’s (win 7 and XP). if u suggest me new way, i will be glad to give a try out.

my questions:

  1. how is it possible that the program works in some computer and in some not?
  2. will you put the file in a different place other then the program folder?

(sorry for my English)

  • 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-14T05:18:40+00:00Added an answer on June 14, 2026 at 5:18 am

    How is it possible that the program works in some computer and in some not?

    Because the program depends on something specific to a computer, and this something is different between the two computers. For example, your error message says:

    file not found ‘C:\Users\eli\AppData\Roaming\fourmlinks.txt’

    The program is looking for a file in the Users folder; that is specific to every user on every machine, different users and different machines will have different files.

    will you put the file in a different place other then the program folder

    Will I? No, I can’t because I’m not that user on that machine. If you mean “can my program put the file in a different place …” then yes, it can.

    string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "fourmlinks.txt");
    

    That will get a path to the logged-on user’s private application data. If you have the “fourmlinks.txt” file in this folder on your machine but someone else doesn’t have this file on their machine, then that will work on your machine but not on someone else’s, as you asked.

    string path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
        "fourmlinks.txt");
    

    That will get the path to the installed file. If both you and someone else install the program, then both you and someone else will have the file. If either of you change the file, then the other gets the changes.

    So should you always use GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)? Well, that depends. GetExecutingAssembly().Location is typically a place standard users cannot write to, only read from. If you want users to only read and never write to your data, then that is a good place to put it. If you don’t, then it isn’t.

    If you want to create a new file for users to write to and to read from, then write to Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData). If you want to install some starting data with your application but allow the user to change it, then you should include the starting data file in your application. It will get installed to System.Reflection.Assembly.GetExecutingAssembly().Location. Then your application should do something like:

    string fileName = "fourmlinks.txt";
    string target = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), fileName);
    if (!File.Exists(target))
    {
        string source = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), fileName);
        File.Copy(source, target);
    }
    

    Another important difference between GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) and Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) is that the former is part of your installer packages; if the user uninstalls or updates your application all their runtime changes will be deleted.

    If you want each user to have their own private data that does not get deleted when the application is modified, then you want to use Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).

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

Sidebar

Related Questions

So I made a program that uses four differrent processes to do some stuff.
For an assignment I've made a simple C++ program that uses a superclass (Student)
I have made a script that uses a program called Diascope, its a video
is it possible to install program that i made in VS2008 (FW3.5) on computer
I have made a batch file that call another one program.bat , the first
I made a program in Java that uses two external databases. The paths to
i have a C# program that i made that uses forms to display the
I made a simple program that uses a shared object, opening it with dlopen()
I have a Haskell program that uses Gtk/GtkGLExt and runs fine on Linux (up-to-date
We have a program made in Borland Delphi that uses Word automation to create

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.