WriteDateTime() public method

public WriteDateTime ( DateTimeOffset value ) : void
value DateTimeOffset
return void
Exemplo n.º 1
0
 private async void OnWrite(Object sender, RoutedEventArgs e)
 {
     // 获取本地目录的引用
     StorageFolder local = ApplicationData.Current.LocalFolder;
     // 创建新文件
     StorageFile newFIle = await local.CreateFileAsync("demo.dat", CreationCollisionOption.ReplaceExisting);
     // 打开文件流
     using(IRandomAccessStream stream = await newFIle.OpenAsync(FileAccessMode.ReadWrite))
     {
         // 实例化 DataWriter
         DataWriter dw = new DataWriter(stream);
         // 设置默认编码格式
         dw.UnicodeEncoding = UnicodeEncoding.Utf8;
         // 写入 bool 值
         dw.WriteBoolean(true);
         // 写入日期值
         DateTime dt = new DateTime(2010, 8, 21);
         dw.WriteDateTime(dt);
         // 写入字符串
         string str = "测试文本";
         // 计算字符串长度
         uint len = dw.MeasureString(str);
         // 先写入字符串的长的
         dw.WriteUInt32(len);
         // 再写入字符串
         dw.WriteString(str);
         // 以下方法必须调用
         await dw.StoreAsync();
         // 解除 DataWriter 与流的关联
         dw.DetachStream();
         dw.Dispose();
     }
     MessageDialog msgDlg = new MessageDialog("保存成功。");
     await msgDlg.ShowAsync();
 }
Exemplo n.º 2
0
 public void Write(DataWriter writer)
 {
     writer.WriteInt32((int)t);
     writer.WriteDateTime(time);
     writer.WriteInt64(cc);
     writer.WriteInt64(asdf);
     writer.WriteInt64(peak);
     writer.WriteUInt64(max0);
     writer.WriteUInt64(max1);
     writer.WriteUInt64(ave0);
     writer.WriteUInt64(ave1);
     writer.WriteUInt64(ave);
     writer.WriteUInt64(beat);
     writer.WriteUInt64(noAudio);
     writer.WriteUInt64(audio);
 }