C#學習記錄1

1、文件夾遍歷並獲取匹配文件名

 public static  void ErrorAnalysisTable(string path){
			
		DirectoryInfo root=new DirectoryInfo(path);      // //判斷路徑下誤差分析表並輸出表名
				
			foreach (FileInfo f in root.GetFiles()){
				
				Regex d =new Regex("誤差數據表");
				
				if(d.IsMatch(f.Name)){
					
					Report.Warn("已存在誤差數據表: "+f.Name);
					
				}
			}	                          
			
		}

2、查找數組對應座標

public static void  ClickLocation(string strSelectComponent){
		string[] SelectComponent=new string[]{"","","","","","",""};
		int ListIndex=Array.IndexOf(SelectComponent,strSelectComponent);
		string[] Click=new string[]{"","","","","","",""};
		
		string ClickZB=Click[ListIndex];
		repo.MainWnd_PMS_AzSoft.EleTable.DoubleClick(ClickZB);
		Delay.Milliseconds(200);
		repo.MainWnd_PMS_AzSoft.EleTable.Click(ClickZB);
		Delay.Milliseconds(500);
	}

3、啓動和關閉軟件

Host.Local.RunApplication(FileName,"",WorkDirectory,false);
Host.Local.CloseApplications(processName);

public static void  CloseSoftWare(string processName){
Process[] procs=Process.GetProcessesByName(processName);      //根據進程命獲得指定的進程
			
	foreach(Process pro in procs){            //Process.GetProcesses("");//獲得本機的進                  
			pro.Kill();
	}
} 	

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章