Does anyone knows or have an sample of a bot on how to check the file size of an attachment? The attachment file is in txt format.
BalaReva.Externals package allows the Bot to check the file size BUT this package is not installed yet in our Orchestrator trial/production environments.
Thanks!
I’m not sure how to do this directly with an attachment, but if you use Save Attachments, then you can use the filepath that is returned in the Output property.
the vb.net way to get filesize is like this:
New FileInfo(filepath).Length
![image](https://global.discourse-cdn.com/uipath/original/3X/b/5/b59faf4f7c5053ca6ed2deb7884251f779716ed4.png)
Since you will be dealing with a list of files, you need to either use LINQ or a ForEach to grab the file you want out of the list, or hardcode the first item.
New FileInfo(attachments.First).Length
You could test it with the attachment directly but I am not sure that would work, like this:
New FileInfo(mailmsg.Attachments(0)).Length
You’ll need to research if that is possible.
But, if you use the Save Attachments activity to output the attachments to a list of filepaths, then use what I mentioned above using System.IO.FileInfo()
Regards.
1 Like
i need some help…regarding
to find file size in uipath…i need to write expression for file size and file format
1 Like
Provide some more info please, like what you have tried or any errors you have gotten.
Refer to my previous post, as it shows exactly how to get the file size of a filepath. Also, notice in the image that there are other items that can be used like LastWriteTime etc. Additionally, you can use System.IO.Path. or System.IO.Directory. and it will show a list of other items you can get from a filepath. Please test this in a Write Line or Message Box, and you can see all the information you can get from a file.
Regards.
i need to upload a file under this requirements…
i used get file folder, write line
For one file, you can do this:
filePath = "filepath"
fileSize = New FileInfo(filePath).Length
fileType = Path.GetExtension(filePath)
For multiple files, just replace the filePath assignment with a .GetFiles() and ForEach
ForEach filePath In Directory.GetFiles(directory)
Refer to images below for more options that you can use…
![image](https://global.discourse-cdn.com/uipath/original/3X/7/1/71b7c885ee8d4cf417c4399c0019093bcd6912fc.png)
![image](https://global.discourse-cdn.com/uipath/original/3X/3/8/38911b56625ee16e39d88d588ed2e5878d93275f.png)
Regards
1 Like