// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Web; namespace E { public class Program { public static void Main(string[] args) { string s = "http://domain.com/test.pdf"; s = Uri.EscapeUriString(s); Console.WriteLine(s); string s2 = "http://www.foobar.com/something.ashx?link=http://domain.com/test.pdf"; s2 = Uri.EscapeUriString(s2); Console.WriteLine(s2); string s3 = "http://www.foobar.com/something.ashx?link=http://domain.com/test.pdf"; s3 = Uri.EscapeDataString(s3); Console.WriteLine(s3); } } }