C# No Arguments Being Passed to Main -
i have been trying arguments passed main method in c#. want capture file path double clicked. have files custom extension , when runs open program. part works.
static string file = ""; [stathread] static void main(string[] args) { application.enablevisualstyles(); if (args.length > 0) file = args[0]; application.run(new form1()); } public form1() { initializecontrols(); }
i tried way, not different.
static string file = ""; [stathread] static void main() { application.enablevisualstyles(); string[] args = environment.getcommandlineargs(); if (args.length > 0) file = args[0]; application.run(new form1()); } public form1() { initializecontrols(); }
its worth mentioning have in partial class. don't know if effects directly or not.
i don't need args if can file double clicked feel way, , curious.
what missing preventing me being able pass args main?
if run "ftype" in command prompt program type should appear as:
yourtype="yourprogram.exe" "%1"
if "%1"
doesn't appear in way, association wrong (it won't pass name of file argument). give try.
Comments
Post a Comment