I created a Form Application
and I tried to get the executable path, and I find this :
System.Reflection.Assembly.GetExecutingAssembly().Location;
System.IO.Path.GetDirectoryName;
but when I puted in my code I had a lot of errors .
This is my code :
namespace inst
{
public class Program
{
System.Reflection.Assembly.GetExecutingAssembly().Location;
System.IO.Path.GetDirectoryName;
[STAThread]
static void Main()
{
}
}
It is right where I placed it? And I want to use that location to find a text file, to be able to change, like here:
private void Form1_Load(object sender, EventArgs e)
{
this.Text = File.ReadLines(Program.Path)
.First(x => x.StartsWith("Title=\""))
.Split(new[] { '=', '"' }, StringSplitOptions.RemoveEmptyEntries)[1];
}
The Path is the location of the file text.
So I want to get de location of executable where is a file test.txt
, put the location in a variabile and use that variabile in form1
and form2
, in my case