I have a little command line app tool xyz.exe
that accepts a filename f
as argument and then will call a program abc.exe
that lives in the same folder as xyz.exe
with some data as argument plus f
.
The ideia would be to drag and drop some file from windows explorer into my program so it calls abc.exe
with the proper parameters. When I say to drop into my program, I mean to drop the file into abc.exe
, so it runs it with the filename as argument.
The problem is that I need a way to know in which folder abc.exe is. I know it will be the same folder as xyz.exe
, but it seems that in drag and drop operations Environment.CurrentDirectory
will show up some windows folder instead of the folder where abc.exe
/xyz.exe
reside.
How can I solve this?
You can do :
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
to find the current directory.