I need to read a text file from the bin.
I use Application.StartupPath
of windows forms ,
but this one brings me another route.
I need to read a text file from the bin.
I use Application.StartupPath
of windows forms ,
but this one brings me another route.
You could use the AppDomain.CurrentDomain.BaseDirectory
method, this will return all the relative path of where the executable ( .exe
) of your application is.
I already solved the problem in the following way:
Assembly assembly = Assembly.GetExecutingAssembly();
string location = assembly.CodeBase;
string fullPath = new Uri(location).LocalPath;
string directoryPath = Path.GetDirectoryName(fullPath);
StreamReader File = new StreamReader(directoryPath + "\BD.hys");