File.Exists(file)为啥执行不下去?


using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.IO;

namespace WpfApp15
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            MainWindow win = new MainWindow();
            if (e.Args[0].Length > 0)
            {
                string file = e.Args[0];
                if (File.Exists(file))
                    win.LoadFile(file);

            }
            win.Show();
        }
    }
}

这里File.Exists(file)为啥执行不下去?string file=e.Args[0]是获取到demo.txt的

img

最后一个图的demo.txt鼠标右键 属性,然后 在复制到输出目录 里选择“始终复制”(或者如果较新复制)

提示:因为调试默认运行目录是debug目录,你得确保debug目录下有这个文本