从命令提示符调用控制台应用程序

时间:2016-01-12 18:17:28

标签: c# asp.net visual-studio-2012 console-application exe

我使用visual studio 2012创建了一个新的控制台应用程序。然后我导航到项目“... \ bin \ debug”中的以下位置,然后将.exe文件复制到C. 现在我想从命令提示符调用此.exe文件,所以我写了以下内容: -

rsync -avu --delete --exclude-from 'dont-remove-these-files.txt' MyLocalFolder/. MyRemoteFolder

但是我收到以下错误: -

C:\>ConsoleApplication1.exe

这是我的控制台应用程序主要方法: -

'ConsoleApplication1.exe' is not recognized as an internal or external command,
operable program or batch file.

如果我使用记事本打开.exe文件,我会得到以下内容,其中包含配置而不是实际的方法代码......: -

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            using (SkillManagementEntities sd = new SkillManagementEntities())
            {
                sd.Levels.Add(new Level() { Name = "from CA" });
                sd.SaveChanges();
            }

        }
    }
}

这是我复制的文件: -

enter image description here

1 个答案:

答案 0 :(得分:6)

您可能隐藏了文件扩展名,这意味着您也可能复制了ConsoleApplication1.exe.config而不是ConsoleApplication1.exe,但是您应该将两者都存在于要执行程序的文件夹中。复制它时,您可能会将ConsoleApplication1.exe.config复制到ConsoleApplication1.exe,意外删除了原始的.config扩展名。