Encode String for File Download from Browser

Hello,

I have a file that the robot uploads into SP and creates a download link in an email to this file. Whenever this file has a “&” in the filename, the download link fails since “&” should really be a “%26” for it work. Does UiPath have any built-in methods/activities for facilitating this encoding?

See example below:
This one doesn’t work:
/sites/teams/roboticsqa/DocumentCenter/BotID-1/Error-UK%20T&E%20Single%20-%20Partnerships-2019-02-04%2010-45-31.xlsm

This one works:
%2Fsites%2Fteams%2Froboticsqa%2FDocumentCenter%2FBotID-1%2FUK%20T%26E%20Single%20-%20Partnerships-2019-02-04%2011-12-29.xlsm

Hi @ramirezp,
For encoding try using
System.Web.HttpUtility.HtmlEncode(string)
For decoding try using
system.Web.HttpUtility.HtmlDecode(string)

1 Like

Thanks Naveen. However, this changes the & to & and not to %26. Is there a URL encode method as opposed to HTML?

Best,

cid:image006.png@01D05A95.A22A1C00

Paul Ramirez

Finance

3501 Corporate Parkway

Center Valley, PA 18034

610.882.6437

dnb.com

cid:image002.png@01D05044.5C2AEE60cid:image003.png@01D05044.5C2AEE60cid:image004.png@01D05044.5C2AEE60cid:image005.png@01D05044.5C2AEE60

I know this is a bit old, but for anyone else who is looking for the solution try

URI.EscapeDataString(Yourstringhere)

Thank you. I hope this will work for all sorts of file name conversion in case of replacing the text in Url and downloading.