如何实现在程序图标上拖动任意文件图标的效果?也就是说,我想使它,如果我拖动一个文件到我的程序,程序启动并打开这个文件。在图中,MyProgram是我编写的C#程序。文件是我想打开的文件。
发布于 2017-03-26 18:15:11
正如Jens评论的那样,您可以检查Environment.GetCommandLineArgs
,或者只使用main方法参数:
public static void Main(string[] args)
{
if (args.Length > 0)
Console.WriteLine(args[0]); // Here's the file path
}
https://stackoverflow.com/questions/43032627
复制相似问题