How to change string path extension in C #?

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

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

Thanks.

+7
source share
4 answers
 string strFile = @"http://login.contentraven.com/Uploads/g05fgxeto4dvsf5531yb3l45_16_8_2011_1_25_37.DOC"; string strTemp = Path.GetExtension(strFile).ToLower(); if (strTemp==".doc") { strFile = Path.ChangeExtension(strFile, "pdf"); } 
+7
source
 string pdfFile = Path.ChangeExtension(strFile, ".pdf"); 
+21
source

Like this for example

 string strFile = @"http://login.com/Uploads/g05fgxeto4dvsf5531yb3l45_16_8_2011_1_25_37.doc"; string newString = String.Format("http://login.com/Uploads/{0}", strFile.Split('/').Last()); 
0
source
 string strFile=@ "http://login.contentraven.com/Uploads/g05fgxeto5531yb3l45_16_8_2011_1_25_37.DOC"; string strTemp = Path.GetExtension(strFile).ToLower(); if (strTemp==".doc") { strFile = Path.ChangeExtension(strFile, "pdf"); } 
0
source

All Articles