@rkelchuri, @Ninett_Panfir, @Rammohan91, @balupad14, @Florent_Salendres, @vvaidya, @Palaniyappan, @ClaytonM, @vvaidya, @lakshman, @Dave
I need to check the presence in a folder of input for the bot the types of files present.
I need to have a xaml thata performs the following checks:
- the folder must contain only zip folders, each other folder or file with other extension must be moved away,
- i need to analyze the content of each zipped folder; the zipped folder must contain only .xml files.
If a zipped folder contains files with other extension, the zipped folder must be moved away.
Can you please provide me a sample workflow that does this?
I’d have to do some verification before giving an answer for #2. However, #1 is an easy enough solution.
All within a for each activity (TypeArgument = string)
For each file in Directory.GetFiles(YourFilePathStringVariable)
If file like "*.zip"
Then (leave true side blank)
Else Move file activity to new location.
how to analyze the content of the zip folder?
The Directory.GetDirectories("", "", SearchOption.AllDirectories).Count() doesn’t count the zip folders.
Cna you help me?
Yes, the zip file isn’t a directory so you can’t use the same method. It should be accessible using a combination of ZipFile, ZipArchive, and ZipArchiveEntry but for some reason the System.IO.Compression.FileSystem namespace isn’t able to be imported in UiPath. Looking back through the forums it looks like the .XAML can be edited with a text editor to manually add that namespace, but I am not familiar enough with manual manipulation of .XAMLs to do that.
If you get that namespace imported, then the instructions would be as follows:
Assign YourZipArchiveVariable = ZipFile.Open(FilePathOfZipAsStringVariable)
For Each zipFile in YourZipArchiveVariable.Entries (make sure TypeObject is ZipFileEntry)
If zipFile.Name like "*.xml"
Then (leave this side blank)
Else Assign boolBadFiles = True
Next Zip File
If boolBadFiles = True
Then Move zip file elsewhere
Else (leave this side blank)