vendredi 8 septembre 2017

how to replace some text and again assign it to same string in c#

In my application I will get the file name with -b. I need to replace the -b and after replacing it I need to again add that filename to the doc. How can I do this?

The filename in doc is 123-b.docx, I need to replace the -b, then after replacment I should get 123.doc this should be given to doc.

if (ddlstype.SelectedValue == "1")
{
    doc = filup1.FileName;
    if (doc.ToLower().Replace("-b", "").ToString())
    {

    }

    ReadFiles(doc1, doc2, ""); 
}
else if (ddlstype.SelectedValue == "2")
{   
    ReadFiles(doc1, "" , ""); 
}
else if (ddlstype.SelectedValue == "3")
{       
    ReadFiles(doc1,"", doc2); 
}

I am getting this error:

Cannot implicitly convert type string to bool near:
if (doc.ToLower().Replace("-b", "").ToString())

Aucun commentaire:

Enregistrer un commentaire