c# - Medication reminder app -
i creating medication reminder app , here how works; creates directory store new medications' details user enters them, these stored text file name of medication file identifier. user able view list of stored medications , details of method searches directory. however, upon deleting 1 medication file directory, name remains in listbox shows existing names, can still create new file same name , names displayed together. think failing clear contents of listbox shows list of existing files have tried best still cannot working. code use deleteing file follows:
try { // string filename = medlistbox.selecteditem.tostring() + ".txt"; isolatedstoragefile storageaccessor = isolatedstoragefile.getuserstoreforapplication(); /*while (storageaccessor.fileexists(filename)) storageaccessor.deletefile(filename);*/ storageaccessor.createdirectory("medicationdetails"); // string fileholderreappear = medlistbox.selecteditem.tostring() + ".txt"; storageaccessor.deletefile(medlistbox.selecteditem.tostring() + ".txt"); messagebox.show("deleted successfully!"); using (var isofilestream = new isolatedstoragefilestream("meddetailsfile.txt", filemode.open, storageaccessor)) { string buff; using (var isofilereader = new streamreader(isofilestream)) { while ((buff = isofilereader.readline()) != null) { medlistbox.items.remove(buff); } } } navigationservice.navigate(new uri("/medicationlist.xaml", urikind.relative)); } catch (exception exception3) { messagebox.show("error!!", exception3.message, messageboxbutton.ok); } }
Comments
Post a Comment