如果我使用ShellExecute(或在.net中System.Diagnostics.Process.Start())运行进程,则启动文件名进程不需要是完整路径.
如果我想开始记事本,我可以使用
Process.Start("notepad.exe");
Run Code Online (Sandbox Code Playgroud)
代替
Process.Start(@"c:\windows\system32\notepad.exe");
Run Code Online (Sandbox Code Playgroud)
因为direcotry c:\windows\system32是PATH环境变量的一部分.
如何在不执行进程且不解析PATH变量的情况下检查PATH上是否存在文件?
System.IO.File.Exists("notepad.exe"); // returns false
(new System.IO.FileInfo("notepad.exe")).Exists; // returns false
Run Code Online (Sandbox Code Playgroud)
但我需要这样的东西:
System.IO.File.ExistsOnPath("notepad.exe"); // should return true
Run Code Online (Sandbox Code Playgroud)
和
System.IO.File.GetFullPath("notepad.exe"); // (like unix which cmd) should return
// c:\windows\system32\notepad.exe
Run Code Online (Sandbox Code Playgroud)
是否有预定义的类可以在BCL中执行此任务?
我正在学习MVC.我只需要澄清一些事情.我正在关注这个教程.这个人使用LocalDB来存储Movie对象.他只是添加一个连接字符串,然后在添加控制器后,如教程中所述,自动添加CRUD操作方法.那家伙使用了类似的句子,"你只需要将你的电影对象存储在localdb中".自动创建数据库(代码优先方法).(我知道如何使用Entity Framework,我们必须创建一些模型来映射我们的数据库).但是这个教程让我很困惑.关于创建数据库等没有提及,而他的连接字符串包含一个单词" Movie.mdf "(在数据源下).最后,跟着他,我发现服务器未找到错误(26).我错过了什么,作为MVC的新手?