/// <summary>将日志信息转化为字符串。</summary> /// <param name="usnCurrentJournalState">当前日志信息</param> /// <returns></returns> private string[] FormatUsnJournalState(USN_JOURNAL_DATA usnCurrentJournalState) { List <string> list = new List <string>(8); list.Add(string.Format("日志ID: {0}", usnCurrentJournalState.UsnJournalID.ToString("X"))); list.Add(string.Format("第一个USN: {0}", usnCurrentJournalState.FirstUsn.ToString("X"))); list.Add(string.Format("下一个USN: {0}", usnCurrentJournalState.NextUsn.ToString("X"))); list.Add(string.Empty); list.Add(string.Format("最小有效USN: {0}", usnCurrentJournalState.LowestValidUsn.ToString("X"))); list.Add(string.Format("最大USN: {0}", usnCurrentJournalState.MaxUsn.ToString("X"))); list.Add(string.Format("最大体积: {0}", usnCurrentJournalState.MaximumSize.ToString("X"))); list.Add(string.Format("单次增长体积: {0}", usnCurrentJournalState.AllocationDelta.ToString("X"))); return(list.ToArray()); }
private void btnQueryUsnJournal_Click(object sender, EventArgs e) { lbResults.DataSource = null; lbResults.Items.Clear(); USN_JOURNAL_DATA journalState = new USN_JOURNAL_DATA(); NtfsUsnJournal.UsnJournalReturnCode rtn = _usnJournal.GetUsnJournalState(ref journalState); lblElapsedTime.Visible = true; lblElapsedTime.Text = string.Format("执行用时:{0}ms", NtfsUsnJournal.ElapsedTime.Milliseconds.ToString()); lblListCount.Text = string.Empty; if (rtn == NtfsUsnJournal.UsnJournalReturnCode.USN_JOURNAL_SUCCESS) { lbResults.Items.AddRange(FormatUsnJournalState(journalState)); } else { lbResults.Items.Add(string.Format("{0} 执行失败!错误码: {1}。", "GetUsnJournalState()", rtn.ToString())); } }