How can I check if the folder is inside c drive, if is not inside, create new folder.
Use If Activity with if conditions
Not System.io.file.exist("C:\FolderName")
Place the Create folder activity and pass the same path.
If there is no solder in a preferred location, the bot will create the folder, else it won’t.
HI @C99
You can try with is expression in the If Activity
not System.IO.File.Exists("Your folder")
Regards
Gokul
HI @C99
Try this expression directly in the if condition
Directory.Exists("C:\Users\UserName\Documents\")
If true → leave empty there
If False-> Create Folder
And that warning symbol is because you are using hardcorded path in the Field so you create a variable to store that path
Regards
Sudharsan
thankyou, it works
hi, can i ask how to name my new folder the same month as one of the directory name in c drive. For example, from c drive, i have to check that the there is a folder named “2022 Folder”, i have to get the year, then from there i name the new folder as “2022 sheet”, if is “2023 Folder”, i name my new folder as “2023 sheet”.
HI @C99
Just use like this in the Create folder activity
"C:\Users\UserName\Documents\"+DateTime.Now.ToString("yyyy")
DateTime.Now.ToString("yyyy")-> This will get the current year (2022)
DateTime.Now.AddYears(-1).ToString("yyyy") -> this will get the previous Year (2021)
DateTime.Now.AddYears(1).ToString("yyyy")-> this will get the Next Year (2023)
Regards
Gokul
What about i need to get the year from the existing folder, but not from getting current year.
Hi @C99
This is the Input folder
To get the Folder Name
Directory.GetDirectories("C:\Users\Dell\Documents\UiPath\Test\2022\")
Output
It will get only the folder name
Path.GetFileNameWithoutExtension(ArrString(0))
Check out this Tutorial for reference
Regards
Gokul
hi, how can i check the folder name itself or must check through directory, if there is a “-” inside folder name, it shows error
okay, thank you
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.