c# - Delete word in textbox -
user write sentence in textbox want delete word in sentence after save file.
for example user write
hi name john
it should output
hi john
string lines = savetxtbox.text; string newlines; //string removedbreaks = line.replace("\r\n", replacewith).replace("\n", replacewith).replace("\r", replacewith); newlines = lines.replace("name"," "); savefiledialog sfd = new savefiledialog(); sfd.filter = "text documents (*.txt)|*.txt|all files (*.*)|*.*"; sfd.filename = datetime.now.toshortdatestring(); if (sfd.showdialog() == dialogresult.ok) { totxt(newlines, sfd.filename); }
but save file cannot delete name word.
i tried this, worked fine.
string lines = savetxtbox.text; string newlines = lines.replace("ynatext.", " "); savefiledialog sfd = new savefiledialog(); sfd.filter = "text documents (*.txt)|*.txt|all files (*.*)|*.*"; sfd.filename = datetime.now.toshortdatestring(); if (sfd.showdialog() == dialogresult.ok) { system.io.file.writealltext(sfd.filename, newlines); }
do remember need have exact string ynatext. (with period in end) replace it.
Comments
Post a Comment