C# 从C向控制台应用程序传递参数#
我需要从另一个c#应用程序运行控制台应用程序,如何从我的c#应用程序加载参数并将参数传递给控制台应用程序,以便执行控制台应用程序。C# 从C向控制台应用程序传递参数#,c#,C#,我需要从另一个c#应用程序运行控制台应用程序,如何从我的c#应用程序加载参数并将参数传递给控制台应用程序,以便执行控制台应用程序。 System.Diagnostics.ProcessStartInfo是否有帮助 对于进程.Start,第二个参数是应用程序的参数: Process.Start("IExplore.exe", "www.northwindtraders.com"); 上面的例子来自。这包含更多关于如何启动流程的示例。使用ProcessStartInfo类 Proce
System.Diagnostics.ProcessStartInfo是否有帮助 对于
进程.Start
,第二个参数是应用程序的参数:
Process.Start("IExplore.exe", "www.northwindtraders.com");
上面的例子来自。这包含更多关于如何启动流程的示例。使用ProcessStartInfo类
ProcessStartInfo p = new ProcessStartInfo();
p.Arguments = "your arguments";
p.FileName = "Application or Document Name";
Process.Start(p);
public IList<string> GetMatchingWords(string word)
{
var list = new List<string>();
int levelDepth = 0;
if (string.IsNullOrEmpty(word))
return list;
var tempWord = word[0];
var firstNode = RootNode.Childs.FirstOrDefault(x => x.Word[0].Equals(tempWord));
if (firstNode == null)
{
return list;
}
var nodePath = new Queue<TrieNode>();
var sb = new StringBuilder();
sb.Append(firstNode.Word);
while (firstNode != null)
{
levelDepth++;
if (levelDepth == word.Length)
{
break;
}
tempWord = word[levelDepth];
firstNode = firstNode.Childs.FirstOrDefault(x => x.Word[0].Equals(tempWord));
sb.Append(firstNode.Word);
}
if(firstNode!=null)
nodePath.Enqueue(firstNode);
originalValue = sb.ToString();
while (nodePath.Any())
{
var tempNode = nodePath.Dequeue();
tempNode.IsParentNode = true;
PopulateWords(tempNode, sb, ref list);
}
return list;
}
private void PopulateWords(TrieNode node,
StringBuilder sb,ref List<string> list)
{
if (node.Childs.Any())
{
foreach (var temp in node.Childs)
{
if (node.IsParentNode)
{
sb.Clear();
sb.Append(originalValue);
}
if (temp.Childs.Any())
{
sb.Append(temp.Word);
PopulateWords(temp, sb, ref list);
}
else
{
sb.Append(temp.Word);
list.Add(sb.ToString());
}
}
}
else
{
list.Add(sb.ToString());
}
}
ProcessStartInfo p=newprocessstartinfo();
p、 Arguments=“您的论点”;
p、 FileName=“应用程序或文档名称”;
进程启动(p);
公共IList GetMatchingWords(字符串字)
{
var list=新列表();
int levelDepth=0;
if(string.IsNullOrEmpty(word))
退货清单;
var tempWord=word[0];
var firstNode=RootNode.Childs.FirstOrDefault(x=>x.Word[0].Equals(tempWord));
if(firstNode==null)
{
退货清单;
}
var nodePath=新队列();
var sb=新的StringBuilder();
sb.Append(firstNode.Word);
while(firstNode!=null)
{
levelDepth++;
if(levelDepth==单词长度)
{
打破
}
tempWord=word[levelDepth];
firstNode=firstNode.Childs.FirstOrDefault(x=>x.Word[0].Equals(tempWord));
sb.Append(firstNode.Word);
}
if(firstNode!=null)
nodePath.Enqueue(第一个节点);
原始值=sb.ToString();
while(nodePath.Any())
{
var tempNode=nodePath.Dequeue();
tempNode.IsParentNode=true;
填充词(临时节点、sb、参考列表);
}
退货清单;
}
私有void PopulateWords(三节点,
StringBuilder sb,参考列表)
{
if(node.Childs.Any())
{
foreach(node.Childs中的变量temp)
{
if(node.IsParentNode)
{
(某人清楚地);
附加(原始值);
}
if(临时Childs.Any())
{
某人附加(临时单词);
填充词(临时、sb、参考列表);
}
其他的
{
某人附加(临时单词);
添加(sb.ToString());
}
}
}
其他的
{
添加(sb.ToString());
}
}
我们可以通过两种方式将参数传递给控制台应用程序。在这里,我已经编写了一个程序,展示了这两种方法。我认为这将是非常有用的
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace ProcessSample
{
class ClsProcess
{
void OpenProcessWithArguments()
{
Process.Start("IExplore.exe", "www.google.com");
}
void OpenProcessWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.google.com";
Process.Start(startInfo);
}
static void Main()
{
ClsProcess myProcess = new ClsProcess();
myProcess.OpenProcessWithArguments();
myProcess.OpenProcessWithStartInfo();
}
}
}