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:
- how is it possible that the program works in some computer and in some not?
- will you put the file in a different place other then the program folder?
(sorry for my English)