I am using File.exists() method to check if the file exists but it returns true even if its in lower case or Upper case but I want to check if file exists with exact name and want it to be case sensitive.
I tried with directory.get files but its case insensitive too.
for example:
New_Test.pdf → should return true - > returns true
NEW_Test.pdf → should return false- > but returns true
new_Test.pdf → should return false- > but returns true
nEW_Test.pdf → should return false- > but returns true
In UiPath, the File.Exists() method and the Directory.GetFiles() method are case-insensitive by default. If you want to perform a case-sensitive file existence check, you can use the Directory.EnumerateFiles() method along with a custom compare.
directoryPath = "C:\YourDirectoryPath"
fileName = "New_Test.pdf"
fileNames = Directory.EnumerateFiles(directoryPath, fileName, SearchOption.TopDirectoryOnly)
For Each file In fileNames
If String.Equals(file, fileName, StringComparison.Ordinal) Then
End If
Next
By using the StringComparison.Ordinal option in the String.Equals() method, you can ensure that the file existence check is case-sensitive.
I think I got why I am getting wrong output Directory.GetFiles(in_Config(“FolderPath”).ToString,CurrentRow(“Name”).ToString + “*.pdf”).Except(System.IO.Directory.GetFiles(in_Config(“FolderPath”).ToString).Select(Function(f) System.IO.Path.GetFileName(f))).Count=0
Directory.GetFiles(in_Config(“FolderPath”).ToString,CurrentRow(“Name”).ToString + “*.pdf”) return the whole path not just the file name
Please add .Select(Function(f) System.IO.Path.GetFileName(f)) after pdf")
But what do you want compare with? Your expression seems to compare with same files.