http://en.wikipedia.org/wiki/.NET_Framework” rel=“noreferer”>。 它对 Java的申请没有照顾到“违约”目录,但 Java申请只搜查现有目录支持档案而告失败。
是否有程序参数可以确定,以确定启动程序的违约目录?
http://en.wikipedia.org/wiki/.NET_Framework” rel=“noreferer”>。 它对 Java的申请没有照顾到“违约”目录,但 Java申请只搜查现有目录支持档案而告失败。
是否有程序参数可以确定,以确定启动程序的违约目录?
Yes! ProcessStartInfo Has a property called WorkingDirectory, just use:
...
using System.Diagnostics;
...
var startInfo = new ProcessStartInfo();
startInfo.WorkingDirectory = // working directory
// set additional properties
Process proc = Process.Start(startInfo);
使用ProcessStartInfo.Working Directory )。 如果不确定财产,违约工作名录为SYSTEMROOT%system32。
You can determine the value of %SYSTEMROOT% by using:
string _systemRoot = Environment.GetEnvironmentVariable("SYSTEMROOT");
下面是开放“灯塔”的样本代码。 拥有一定比例的ProgramFiles%的工作名录:
...
using System.Diagnostics;
...
ProcessStartInfo _processStartInfo = new ProcessStartInfo();
_processStartInfo.WorkingDirectory = @"%ProgramFiles%";
_processStartInfo.FileName = @"Notepad.exe";
_processStartInfo.Arguments = "test.txt";
_processStartInfo.CreateNoWindow = true;
Process myProcess = Process.Start(_processStartInfo);
还有一个环境变量,可以控制你通过Environment.CurrentDirectory Property .
Just a note after hitting my head trying to implement this. Setting the WorkingDirectory value does not work if you have "UseShellExecute" set to false.
利用该程序。 工作 名录财产。
http://msdn.microsoft.com/en-us/library/system.diagnostics.startprocessinfo.workingdirectory.aspx”rel=“noretinger”>here。
这一进程。 起始方法具有超负荷,采用程序StartInfo。 这一类财产称为“工作名录”。
赋予你希望使用的双管齐下的财产,这应当使其以正确的方式开始。
使用<代码>ProcessStartInfo等值,并分配WorkingDirectory
property。
I was in a catch 22 like @cbbspike as I wanted to have both UseShellExecute
equal to false
and set the WorkingDirectory
to where the EXE should start. So I took @larry-smithmier answer and set the Environment.CurrentDirectory
as he suggested.
注:我确实是<>而不是不得不在引文中填上目录。 在我的情况下,<代码>字母代码> <代码>C:ProgramfilesSomeDir
Environment.CurrentDirectory = scriptsPath;
ProcessStartInfo processStartInfo = new ProcessStartInfo("powershell.exe", scriptArguments);
processStartInfo.UseShellExecute = false;
//processStartInfo.WorkingDirectory = // intended working directory
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...