尝试调试通过打开与打开要调试的应用程序相关的文本文件而打开的应用程序。有没有办法启动调试并等待应用程序被调用,而无需执行“启动外部程序”启动操作?
最终,我试图获取打开应用程序的文本文件的文件信息,以便可以在应用程序中将其用作“保存的项目”文件。
我有一个名为“ myFile.cats”的文本文件,我已将此文件扩展名与由Visual Studio应用程序在调试箱中创建的可执行解决方案关联打开。
我已经尝试过使用StartupEventArgs,但是它显然没有返回任何东西,因为它不是从外部文件中调用的。因此,我似乎没有一种测试方法来确保它可以正常工作...
任何帮助将不胜感激。
using Caliburn.Micro;
using ApplicationWPFUI.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using ApplicationLibrary;
namespace ApplicationWPFUI
{
public class Bootstrapper : BootstrapperBase
{
public Bootstrapper()
{
Initialize();
}
//myFile.cats File opens this exe and the 'OnStartup' runs, where is the myFile.cats information being passed in?
protected override void OnStartup(object sender, StartupEventArgs e)
{
if (e.Args.Count() != 0)
{
//Save the startupEventArgs to a variable
GlobalConfigs.FileList.Files = e.Args.ToList();
}
DisplayRootViewFor<MainViewModel>();
}
}
}
我已经正确地进行了此操作,只需要进行一点点更改。打开应用程序的文件所需的信息在GlobalConfigs.FileList.Files = e.Args.ToList();
中。但是,我只需要该列表中的第一个变量。
因此调用以下命令就可以了:
GlobalConfigs.FileList.Files = e.Args[0].ToString();
显然,StartupEventArgs
并不总是在其中包含信息,因为我将自己调用应用程序并使用关联文件打开它。因此,我只是将其包装在if语句中:
if (e.Args.Count() != 0) {
GlobalConfigs.FileList.File = e.Args[0].ToString();
}
还有你叔叔鲍勃。