Problem with access to file
Posted
by phenevo
on Stack Overflow
See other posts from Stack Overflow
or by phenevo
Published on 2010-05-13T16:20:08Z
Indexed on
2010/05/13
16:24 UTC
Read the original article
Hit count: 172
Hi,
I have winforms application and it has reference to library MyLibrary.
MyLibrary has method:
string[] GiveMeNamesOfAirports()
{
string[] lines= File.ReadLines("airports.txt");
foreach(string line in lines)
...
}
And when I run my Winforms application:
I get error:
file couldn't be find.
I was trying other function:
string[] lines = File.ReadAllLines(Path.Combine(System.Environment.CurrentDirectory, "airports.txt"));
string[] lines = File.ReadAllLines(Path.Combine(Assembly.GetExecutingAssembly().Location, "airports.txt"));
string[] lines = File.ReadAllLines(Path.Combine(Assembly.GetAssembly(typeof(Airport)).Location, "airports.txt"));
© Stack Overflow or respective owner