private async void OnRead(Object sender, RoutedEventArgs e) { StorageFolder local = ApplicationData.Current.LocalFolder; StorageFile file = await local.GetFileAsync("demo.dat"); if(file != null) { string strres = "读到的内容:\n"; using(IRandomAccessStream stream = await file.OpenReadAsync()) { DataReader dr = new DataReader(stream); dr.UnicodeEncoding = UnicodeEncoding.Utf8; await dr.LoadAsync((uint)stream.Size); bool b = dr.ReadBoolean(); strres += b.ToString() + "\n"; DateTimeOffset dt = dr.ReadDateTime(); strres += dt.ToString("yyyy-M-d") + "\n"; uint len = dr.ReadUInt32(); if(len > 0) { strres += dr.ReadString(len); } dr.Dispose(); } tbResult.Text = strres; } }
public void Read(DataReader reader) { t = (HeartBeatType)reader.ReadInt32(); time = reader.ReadDateTime().UtcDateTime; cc = reader.ReadInt64(); asdf = reader.ReadInt64(); peak = reader.ReadInt64(); max0 = reader.ReadUInt64(); max1 = reader.ReadUInt64(); ave0 = reader.ReadUInt64(); ave1 = reader.ReadUInt64(); ave = reader.ReadUInt64(); beat = reader.ReadUInt64(); audio = reader.ReadUInt64(); noAudio = reader.ReadUInt64(); }