I am trying to display a URL in my sharepoint list programmatically and the filename has some spaces , so by default it is taking %20 . how can i stop this behaviour , how can i show original filename with the spaces .
Asked
Active
Viewed 551 times
0
-
1Duplicate http://stackoverflow.com/questions/1517586/how-do-i-replace-all-the-spaces-with-20-in-c-sharp – nobody Feb 25 '16 at 05:03
-
1You can follow @inquisitive_mind's link ... except it seems like you want the opposite of that answer (you want `UrlDecode` instead if you're displaying a URL in a list). – Simon Whitehead Feb 25 '16 at 05:04
-
yes i did that but it is showing page not found error . so i want the exact filename with the spaces – Revenant_01 Feb 25 '16 at 05:04
-
@SimonWhitehead i tried that UrlDecode , but the problem is that in my code when i checked for if(string.contains(%20)) {string.urldecode} it doesnt work because there is no %20 , it is getting generated at the runtime. – Revenant_01 Feb 25 '16 at 05:07
1 Answers
1
using System.Net;
You can decode it as below:
string yourFileNameinURL = "My%20Name";
string yourFileNameYouWant = WebUtility.UrlDecode(yourFileNameinURL);
Console.WriteLine(yourFileNameYouWant);

NoName
- 7,940
- 13
- 56
- 108