1

I have a simple C# application that must run a console application as one step. I've seen a few posts on including executables as embedded resources and running them through memory streams but that doesn't look like the easiest way.

I'm thinking it would be better to just copy the .exe to the content folder and run it with a good ol' Process.Start from there.

The question is, how do you find the content folder for an application?

I can get it done this way, but it seems roundabout:

//Run Executable
StreamResourceInfo info = Application.GetContentStream(new Uri("MyApp.exe", UriKind.Relative));
string AppName = (info.Stream as FileStream).Name;

any tips?

4

1 に答える 1

1
Path.GetDirectoryName(Application.ExecutablePath);

次に、Path.Combine を使用して、contents サブディレクトリまたは他のアプリがあるディレクトリに移動できます。

于 2012-06-05T21:04:59.213 に答える