其他 Others - YenLinWu/RPA_UiPath GitHub Wiki

  • 取得資料夾中所有的檔案路徑 Get a list of files from a Working Directory

arr_AllFiles = Directory.GetFiles( str_FolderPath )

  • 取得資料夾中所有的檔案名稱( 包含副檔名 )
    arr_FileName = ( From item In arr_AllFiles Select Path.GetFilename( item ) ).ToArray
  • 刪除資料夾中所有的檔案 Delete multiple files in a Working Directory

使用 Invoke Code 元件 :
Code = Array.ForEach( Directory.GetFiles( str_FolderPath ), Sub(x) File.Delete(x) )
Language 選擇 VBNet

  • 產生一連續整數序列的列表 Generate a list of integer numbers within a specified range

list_Sequence = Enumerable.Range( int_StarNum, int_Count ).[Select]( Function(x) Convert.ToInt32(x) ).ToList

e.g. 產生一個整數列表 list_Sequence 為 { 2, 3, 4, 5, 6 }
list_Sequence = Enumerable.Range( 2, 5 ).[Select]( Function(x) Convert.ToInt32(x) ).ToList

  • 刪除字串內容中的換行及多餘空白 Delete new line and unwanted space of text

str_Text = String.join( " ", str_Text.Split( {Environment.NewLine,vbcrlf,vblf," ",vbtab,vbcr,vbNewLine}, StringSplitOptions.RemoveEmptyEntries ) )

e.g. 將下列文字刪除換行及多餘的空白
str_Text =
"
WHT applies to certain payments made to foreign organisations and individuals undertaking business or earning income sourced from Vietnam, regardless of the residency status.
WHT rates are nil for dividends. For interest and royalties, please refer to Vietnam's Corporate summary.
"

str_Text = String.join( " ", str_Text.Split({Environment.NewLine,vbcrlf,vblf," ",vbtab,vbcr,vbNewLine},StringSplitOptions.RemoveEmptyEntries) )
Output :
"WHT applies to certain payments made to foreign organisations and individuals undertaking business or earning income sourced from Vietnam, regardless of the residency status. WHT rates are nil for dividends. For interest and royalties, please refer to Vietnam's Corporate summary."

假設 dt_DataTable 變數為下列資料表:

Column1 Column2 Column3
Name Number OK
B 3 True
A 2 True
E 2 False
C 4 True
D 5 True
A 1 False
  • 變更資料表的欄位名稱 Change column names of a DataTable

e.g. 將第一筆資料調整為資料表的欄位名稱

Step 1 : list_ColumnNames = Split( String.join( ",", dt_DataTable.Rows(0).itemArray ), "," ).ToList
Step 2 : 使用 'Remove Data Row' 元件刪除第一筆資料
Step 3 : For Each item in list_ColumnNames
     int_Index = int_Index + 1
     dt_DataTable.Columns( "Column"+int_Index.ToString ).ColumnName = item
    註 : int_Index 變數為 For Each 的 Output 變數

Name Number OK
B 3 True
A 2 True
E 2 False
C 4 True
D 5 True
A 1 False