private void SaveRecordByID(string guid) { StreamReader r = new StreamReader(Server.MapPath("~/tracking.txt")); string json = r.ReadToEnd(); List <Issue> trackedIssues = JsonConvert.DeserializeObject <List <Issue> >(json); //trackedIssues.RemoveAll(l => l.GUID == guid); int index = trackedIssues.FindIndex(m => m.GUID == guid); if (index >= 0) { trackedIssues[index].JIRA = hdnUserInput.Value; } r.Dispose(); //open file stream StreamWriter file = File.CreateText(Server.MapPath("~/tracking.txt")); JsonSerializer serializer = new JsonSerializer(); //serialize object directly into file stream serializer.Serialize(file, trackedIssues); file.Dispose(); TrackedIssues.DataSource = trackedIssues; TrackedIssues.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { StreamReader r = new StreamReader(Server.MapPath("~/tracking.txt")); string json = r.ReadToEnd(); r.Dispose(); List <Issue> trackedIssues = JsonConvert.DeserializeObject <List <Issue> >(json); TrackedIssues.DataSource = trackedIssues; TrackedIssues.DataBind(); } }
private void DeleteRecordByID(string guid) { StreamReader r = new StreamReader(Server.MapPath("~/tracking.txt")); string json = r.ReadToEnd(); List <Issue> trackedIssues = JsonConvert.DeserializeObject <List <Issue> >(json); trackedIssues.RemoveAll(l => l.GUID == guid); r.Dispose(); //open file stream StreamWriter file = File.CreateText(Server.MapPath("~/tracking.txt")); JsonSerializer serializer = new JsonSerializer(); //serialize object directly into file stream serializer.Serialize(file, trackedIssues); file.Dispose(); TrackedIssues.DataSource = trackedIssues; TrackedIssues.DataBind(); }