フォルダ内ののファイルを全て取得(getfilesメソッドで取得)し、フォルダ内のファイル存在有無判定をしようと考えています。
Length=0とcount=0どちらを使おうか悩んでいるのですが、この二つの違いってなんでしょうか
フォルダ内ののファイルを全て取得(getfilesメソッドで取得)し、フォルダ内のファイル存在有無判定をしようと考えています。
Length=0とcount=0どちらを使おうか悩んでいるのですが、この二つの違いってなんでしょうか
Hi @natsumikan
Length: This property is typically used with arrays. It returns the total number of elements in the array.
Example:
array.Length
Count: This property is used with collections such as lists, dictionaries, or enumerable types. It returns the number of elements in the collection.
Example:
list.Count
In your case, if you’re using GetFiles method in UiPath, it returns an array of strings representing the files in the specified directory. Therefore, you should use .Length to get the number of files in the folder.
Example in UiPath:
arrFiles = Directory.GetFiles("C:\YourFolderPath")
If arrFiles.Length > 0 Then
// Files exist
Else
// No files exist
End If
Hope it helps!!