IF activity:
attach.Name.ToString.StartsWith(“QUOTATION”) And
(attach.Name.ToString.ToLower.EndsWith(“.xlsx”) Or attach.Name.ToString.ToLower.EndsWith(“.xls”))
Regex Escape filter for Save Attachments activity:
System.Text.RegularExpressions.Regex.Escape(attach.Name)
Write line output of the regex escape:
QUOTATION-X31976-K645\ (test).xlsx
QUOTATION-X31976-K645.xlsx
test\ QUOTATION-X31976-K645\ -\ Copy.xlsx
test\ QUOTATION-X31976-K645.xlsx
but why the saved attachments are these file:
QUOTATION-X31976-K645 (test).xlsx
QUOTATION-X31976-K645.xlsx
test QUOTATION-X31976-K645.xlsx → i don’t want this file to be saved (look at my IF activity)
Probably the attached files are stored somewhere in file system. And Save Attachment activity seems to filter the full path of attached file with regex pattern.
For example, if the attachment is “test.docx”, the file is strored as c:\somewhere\XXXXXX\test.docx and Save Attachment try to get files using the full path. So this is reason why there is no result if we use ^ meta character in regex.
It might be better the pattern will be "(^|\\)"+System.Text.RegularExpressions.Regex.Escape(attach.Name)+"$", because of prepare for improvement in the future.
i tried to delete my attachment from c:\somewhere\XXXXXX\file test.docx and also delete from recycle bin after i send the file to email as attachment to be saved by RPA.
then i tried to save the attachments using
“\”+System.Text.RegularExpressions.Regex.Escape(attach.Name)+“$”
but it also worked.
then i tried also your 3rd solution
“(^|\)”+System.Text.RegularExpressions.Regex.Escape(attach.Name)+“$”
it also worked.
Well, i’ll just use your 3rd solution just in case of improvement in the future.