Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change extension of string path in C#?

Tags:

People also ask

How do you change a string extension?

Solution. Use string 's rfind and replace member functions to find the extension and replace it.

Can a file's extension be changed?

You can also do it by right-clicking on the unopened file and clicking on the “Rename” option. Simply change the extension to whatever file format you want and your computer will do the conversion work for you.

How do you change the extension of a file using C#?

And finally, if you just want to replace file extension use var newFilePath = Path. ChangeExtension(myffile, ". Jpg"); ; the newFilePath will contain a new file name with changed extension, physically, the file name (on disk) won't be changed.


Below is my string value

string strFile = @"http://login.com/Uploads/g05fgxeto4dvsf5531yb3l45_16_8_2011_1_25_37.doc";

And I need to replace this file path value by

http://login.com/Uploads/g05fgxeto4dvsf5531yb3l45_16_8_2011_1_25_37.pdf

Thanks.