嗨当前我有这个蚂蚁脚本:
<target name="Cleanup Snapshots" description="Cleanup TrueCM snapshots">
<echo>Executing: ${TrueCM_App}\ssremove.exe -h${TrueCM_Host} "${TrueCM_New_SS}"</echo>
<exec executable="${TrueCM_App}\ssremove.exe" failonerror="${TrueCM_Failon_Exec}">
<arg line="-h ${TrueCM_Host}"/>
<arg line='-f "${TrueSASE}/${Product_version}/${name}"'/>
</exec>
</target>
Run Code Online (Sandbox Code Playgroud)
这个脚本的作用是它将使用一些参数执行ssremove.exe,如图所示.
但是,上述脚本仅在参数$ {Product_version}包含单词"Extensions"时才有效,例如6.00_Extensions
否则,如果它们不包含"Extensions",则脚本应如下所示:
<target name="Cleanup Snapshots" description="Cleanup TrueCM snapshots">
<echo>Executing: ${TrueCM_App}\ssremove.exe -h${TrueCM_Host} "${TrueCM_New_SS}"</echo>
<exec executable="${TrueCM_App}\ssremove.exe" failonerror="${TrueCM_Failon_Exec}">
<arg line="-h ${TrueCM_Host}"/>
<arg line='-f "${TrueSASE}/${name}"'/>
</exec>
</target>
Run Code Online (Sandbox Code Playgroud)
所以我的问题是我应该如何添加包含"Extensions"行的if else语句?或者如何检查"Extensions"字词是否存在?
举个例子,我有一个声明的字符串:
string master = "1.2.3.4";
Run Code Online (Sandbox Code Playgroud)
其形式为:
major.minor.project.build
如何从字符串"master"中分别分配字符串"major","minor","project"和"build"?
我知道我们必须做line.split,这就是我尝试过的:
string[] master = line.Split('.');
string major = master[0];
string minor = master[1];
string project = master[2];
string build = master[3];
Run Code Online (Sandbox Code Playgroud) 我如何声明一个带有参数的字符串?
假设
string path = "C:\\Work\\6.70_Extensions\\"
Run Code Online (Sandbox Code Playgroud)
和6.70_Extensions被取代ARGS解析我想这:
string path = ("C:\\Work\\{0}\\NightlyBuild\\", args[0]) ;
Run Code Online (Sandbox Code Playgroud)
其中args [0]是一个字符串.我想我的语法在某处错了
我有这个代码,我将按顺序运行以下代码.
我将始终在开头创建一个新的文本文件.然后对于代码的第2和第3部分,我只需要附加文本文件"checksnapshot"我如何使用streamwriter?
//1
using (StreamReader sr = new StreamReader("C:\\Work\\labtoolssnapshot.txt")) ;
{
string contents = sr.ReadToEnd();
using (StreamWriter sw = new StreamWriter("C:\\Work\\checksnapshot.properties"))
{
if (contents.Contains(args[0]))
{
sw.WriteLine("SASE= 1");
}
else
{
sw.WriteLine("SASE= 0");
}
}
}
//2
using (StreamReader sr = new StreamReader("C:\\Work\\analyzercommonsnapshot.txt")) ;
{
string contents = sr.ReadToEnd();
using (StreamWriter sw = new StreamWriter("C:\\Work\\checksnapshot.properties"))
{
if (contents.Contains(args[0]))
{
sw.WriteLine("Analyzer= 1");
}
else
{
sw.WriteLine("Analyzer= 0");
}
}
}
//3
using (StreamReader sr = new StreamReader("C:\\Work\\mobilesnapshot.txt")) ;
{
string contents = …Run Code Online (Sandbox Code Playgroud) 我在msdn上看到了这篇文章的例子http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
所以我决定尝试一下,在我的wpf应用程序中试试这个:
Dictionary<string, string> Dictionarycheck =
new Dictionary<string, string>();
Dictionarycheck.Add("demo1");
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?我收到错误:无效的标记'('在类,结构或接口成员声明中
我有以下代码:
String Antcbatchpath = @"C:\GUI\antc.bat";
System.Diagnostics.Process runantc = new System.Diagnostics.Process();
runantc.StartInfo.FileName = Antcbatchpath;
runantc.StartInfo.UseShellExecute = false;
runantc.StartInfo.RedirectStandardOutput = true;
runantc.StartInfo.RedirectStandardError = true;
runantc.Start();
Run Code Online (Sandbox Code Playgroud)
这会加载批处理文件C:\GUI\antc.bat吗?
或者runantc.StartInfo.FileName仅用于根目录?根目录是应用程序所在的位置
编辑1:
嗨而不是@"C:\ GUI\antc.bat"我有一个路径:
String Antcbatchpath =@"C:\GUI Lab Tools\Build Machine\antc.bat";
Run Code Online (Sandbox Code Playgroud)
它基本上包含空格.它会影响runantc.StartInfo.Filename = Antcbatchpath;吗?
c# ×5
.net ×1
ant ×1
batch-file ×1
dictionary ×1
file-io ×1
string ×1
version ×1
wpf ×1
xml ×1