English 中文(简体)
NET Process。 启动违约目录?
原标题:.NET Process.Start default directory?
  • 时间:2008-09-22 13:44:33
  •  标签:
  • c#

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);
问题回答

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.

这一进程。 起始方法具有超负荷,采用程序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




相关问题
Anyone feel like passing it forward?

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. ...

NSArray s, Primitive types and Boxing Oh My!

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 ...

C# Marshal / Pinvoke CBitmap?

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 ...

How to Use Ghostscript DLL to convert PDF to PDF/A

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, ...

Linqy no matchy

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. ...

热门标签