Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert/Replace space with %20 and vice versa in c#

Tags:

c#

uri

package

Below is the code to create a zip file and to add files to it.

Problem: Currently, when the zip file is created, the files present in it contains %20 instead of space which is one functionality.I have another requirement to replace %20 with space. How to achieve this in below code.

Removed the code from the post.

like image 451
Gaurav123 Avatar asked Feb 06 '23 17:02

Gaurav123


1 Answers

Here is an example using the Uri static class:

var url = "http://www.somewhere.net/Thingy%20World.html";

var decoded = Uri.UnescapeDataString(url);
//decoded is currently 'http://www.somewhere.net/Thingy World.html'

var encoded = Uri.EscapeUriString(decoded);//back to encoded
//encoded is currently 'http://www.somewhere.net/Thingy%20World.html' 
like image 173
Cubicle.Jockey Avatar answered Feb 16 '23 09:02

Cubicle.Jockey