Get file that spawned the application.
-
Hey Ya'll.. I'm building a little analyzer utility that will analyze text files automatically. Currently you have to click the Open Files button to load a file to analyze. I'd like to mod this program so that if you double click the file you want to analyze, it will spawn the analyzer and automatically analyze the contents of the clicked file. I've set my PC to always Open With the analyzer when you click on the files with my extension, but I'm at a loss on how to get the filename / path of the file that spawned it. Can anyone point me in the right direction? Thanks in advance -Chris
-
Hey Ya'll.. I'm building a little analyzer utility that will analyze text files automatically. Currently you have to click the Open Files button to load a file to analyze. I'd like to mod this program so that if you double click the file you want to analyze, it will spawn the analyzer and automatically analyze the contents of the clicked file. I've set my PC to always Open With the analyzer when you click on the files with my extension, but I'm at a loss on how to get the filename / path of the file that spawned it. Can anyone point me in the right direction? Thanks in advance -Chris
Chris, I'm going to assume that you've set the file type in Folder Options in Explorer to load your application automatically. In the Advanced dialog, you get the command line to run. Using %1 on the command line should give you the FQ path to the file that was double-clicked. Change "c:\program files\myapp\myapp.exe" to "c:\program files\myapp\myapp.exe" %1 Make your Main() into Main(string[] args), and args should contain the path/file that was clicked on. Stephan
-
Hey Ya'll.. I'm building a little analyzer utility that will analyze text files automatically. Currently you have to click the Open Files button to load a file to analyze. I'd like to mod this program so that if you double click the file you want to analyze, it will spawn the analyzer and automatically analyze the contents of the clicked file. I've set my PC to always Open With the analyzer when you click on the files with my extension, but I'm at a loss on how to get the filename / path of the file that spawned it. Can anyone point me in the right direction? Thanks in advance -Chris
It should be passing the filename as the first argument to your app.
void Main(string[] args) { // args[0] should contain your filename if double clicked from explorer under default setup for associating extesions with executables }
Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour -
Chris, I'm going to assume that you've set the file type in Folder Options in Explorer to load your application automatically. In the Advanced dialog, you get the command line to run. Using %1 on the command line should give you the FQ path to the file that was double-clicked. Change "c:\program files\myapp\myapp.exe" to "c:\program files\myapp\myapp.exe" %1 Make your Main() into Main(string[] args), and args should contain the path/file that was clicked on. Stephan
-
Hey Ya'll.. I'm building a little analyzer utility that will analyze text files automatically. Currently you have to click the Open Files button to load a file to analyze. I'd like to mod this program so that if you double click the file you want to analyze, it will spawn the analyzer and automatically analyze the contents of the clicked file. I've set my PC to always Open With the analyzer when you click on the files with my extension, but I'm at a loss on how to get the filename / path of the file that spawned it. Can anyone point me in the right direction? Thanks in advance -Chris
What was working is now not! I'm not exactly sure where the problem resides, but after I built my installer, and installed the application on my PC everything seemed to be fine. Then when I click the log file to analyze, it keeps opening back up using notepad. So I went to Open With.., and browsed to my .exe, and checked the option to always open files with this extention. When I double click the file now I get a critical error stating that the LOG file I double clicked and it's path is not a valid Win32 Application. How do I reset the target so that when I click the log file, it uses my .exe as the application?