0

My application creates files with a ".mhm" extension.

I'd like for my application to open and process these files when I double-click them. Current behavior is that when I double-click the file, my application opens but does not process the file.

How can I read the args parameter of Main() method in C# 2008?

Chris McCall
  • 10,317
  • 8
  • 49
  • 80
mohammad reza
  • 3,292
  • 6
  • 29
  • 39

2 Answers2

2

If I understand your question correctly you just use:

public void static Main(string args[])
{
...
}
Grzenio
  • 35,875
  • 47
  • 158
  • 240
2

"Hi

My Application creates files with the .MHM file extension. I would like my application to be associated with this file extension so that when a MHM file is executed, my application is too, with the file path as the arguments for the main method of my application."

That's what I understood.

Grzenio has the right idea -

public void static Main(string args[])
{ 
...
}

but to push your application into the shell would take extra research, you'd have to look into integrating your application into the Shell (using the registry).

See here: script-to-associate-an-extension-to-a-program

EDIT: Thanks for the edit of the question Chris, trying to see things a bit wider here... Perhaps the arguments solution was all the OP needed.

Community
  • 1
  • 1
Daniel May
  • 8,156
  • 1
  • 33
  • 43