【问题标题】:C# file passed to exe eventC# 文件传递​​给 exe 事件
【发布时间】:2017-07-04 08:40:37
【问题描述】:

我想创建一个可以打开 CSV 文件的程序。我希望能够在 Windows 中右键单击文件名并说用 my.exe 打开。

我需要覆盖 .exe 中的哪些事件来处理传入的文件?

【问题讨论】:

标签: c# file csv exe


【解决方案1】:

这将是论点..

class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.WriteLine(args[0]);  // <-- args[0] contains filename
            }
            Console.ReadLine();
        }
    }

【讨论】:

    【解决方案2】:

    文件名将作为参数传递给您的static void Main(string[] args)

    static void Main(string[] args)
    {
        if (args != null && args.Length > 0)
            Console.WriteLine("File: {0}", args[0]); // Your file
    }
    

    【讨论】:

      猜你喜欢
      • 2011-12-11
      • 2014-09-22
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多