开发者

How do I know what file was opened when someone uses my program with "Open With"?(C#) [duplicate]

开发者 https://www.devze.com 2023-03-13 17:38 出处:网络
This question already has answers here: Handle program being open开发者_Go百科ed by open with? [duplicate]
This question already has answers here: Handle program being open开发者_Go百科ed by open with? [duplicate] (2 answers) Closed 9 years ago.

I wrote a C# program for converting and re-sizing images. If someone opens a bitmap with my program with "Open With...", how do I "handle" that event and figure out which file they just opened?


Locate your Main() method

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

the args gets all the command line parameters and the file name should be in there.


Use System.Environment.GetCommandLineArgs() or String args[] parameter passed to your Main method. The name of the file that is being opened will be there.

0

精彩评论

暂无评论...
验证码 换一张
取 消