I want to know if I can open the "open"-dialogbox from the cmd, so I can use that to choose the right file to open. (I already know how to open the file directly from the cmd, but thats not what I interested in)
At the moment I'm doing a project where i use a program (e.g. program.exe). This program needs a modelfile (e.g. modelfile.mod). I execute the program in the CMD by writing: program.exe modelfile.mod, and it work. I have many modelfiles with different names, but the program file always has the same name. Instead of writing in the CMD every time I need to execute the program I would like to create a batch where I can choose the modfile I like to execute whereafter it executes the program with the chosen modfile as input.
Therefore I need to know how to open the "open"-dialogbox from the cmd, and also how to get the name of the chosen file for use in execution of the program.
If you've got PowerShell installed, you can do something like this:
Or if you want to break down the powershell cmdlets for easier maintenance:
(PowerShell command mercilessly leeched from the Just Tinkering Blog.) See the OpenFileDialog Class documentation for other properties you can set, such as
Title
andInitialDirectory
.