正如标题所述。 我知道如何在C#中做到这一点,但是当试图用WPF来做到这一点时,我无法找到在程序启动时读取文件名的位置或内容。拖放.exe文件顶部的文件以获取文件信息
public static void Main(string[] args)
{
if (Path.GetExtension(args[0]) == ".avi" || Path.GetExtension(args[0]) == ".mkv")
{
string pathOfFile = Path.GetFileNameWithoutExtension(args[0]);
string fullPathOfFile = Path.GetFullPath(args[0]);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(pathOfFile, fullPathOfFile));
}
else
{
MessageBox.Show("This is not a supported file, please try again..");
}
}
退房http://blogs.msdn.com/b/avip/archive/2008/10/27/wpf-supporting-command-line-arguments-and-file-extensions.aspx。它解释了如何阅读WPF中的命令行参数。 – 2010-07-12 17:52:19