Reputation: 5209
I want to remove %20
from file name but it should be in Uri format.
Dictionary<string, Uri> urilist = new Dictionary<string, Uri>();
string fileName="test data.txt";
Uri partUriDocument;
partUriDocument = PackUriHelper.CreatePartUri(new Uri(fileName, UriKind.Relative));
urilist.Add(fileName, partUriDocument);
partUriDocument contains test%20data.txt
.
How to make it test data.txt
.
Upvotes: 2
Views: 1727
Reputation: 2085
What you want to do is called decoding. It's the same mecanic you're using when you go from
string str = "123"; //String
int number = Int.Parse(str) // Decode string into a number
You encode your string in an uri, you decode your uri in a string
Use Uri.Parse
var str = Uri.Parse(Uri);
Upvotes: 0
Reputation: 9649
partUriDocument contains test%20data.txt.
How to make it test data.txt.
You can properly decode it using
var decodedFileName = WebUtility.UrlDecode(fileName); // returns "test data.txt"
Upvotes: 7