當前位置: 首頁>>代碼示例>>C#>>正文


C# StorageFile.OpenSequentialReadAsync方法代碼示例

本文整理匯總了C#中Windows.Storage.StorageFile.OpenSequentialReadAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# StorageFile.OpenSequentialReadAsync方法的具體用法?C# StorageFile.OpenSequentialReadAsync怎麽用?C# StorageFile.OpenSequentialReadAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.Storage.StorageFile的用法示例。


在下文中一共展示了StorageFile.OpenSequentialReadAsync方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeserializeLocalSessions

		public static async Task<List<Session>> DeserializeLocalSessions(StorageFile file) {
			using (var stream = await file.OpenSequentialReadAsync()) {
				using (var dr = new Windows.Storage.Streams.DataReader(stream)) {
					var numberOfSessions = dr.ReadInt32();
					List<Session> rv = new List<Session>(numberOfSessions);
					for (int x = 0; x < numberOfSessions; x++) {
						rv.Add(LoadSession(dr));
					}
					return rv;
				}
			}
		}
開發者ID:Programmerman1,項目名稱:bandcurling,代碼行數:12,代碼來源:Session.cs

示例2: Restore

 public async Task<List<Avalon>> Restore(StorageFile file)
 {
     List<Avalon> Return = new List<Avalon>();
     List<SerializableAvalon> temp = new List<SerializableAvalon>();
     using (IInputStream Stream = await file.OpenSequentialReadAsync())
     {
         DataContractSerializer dcs = new DataContractSerializer(typeof(List<SerializableAvalon>));
         temp = (List<SerializableAvalon>)dcs.ReadObject(Stream.AsStreamForRead());
     }
     foreach (SerializableAvalon item in temp)
     {
         Avalon Pizza = Produce(item.Definition);
         Pizza.RestorState(item);
         Return.Add(Pizza);
     }
     return Return;
 }
開發者ID:MohammedAbuissa,項目名稱:Avalon,代碼行數:17,代碼來源:AFactory.cs

示例3: DeserializeFromFileAsync

 public static async Task<Object> DeserializeFromFileAsync(Type objectType, StorageFile file, bool deleteFile = false)
 {
     if (file == null) return null;
     try
     {
         Object obj;
         AppEventSource.Log.Debug("Suspension: Checking file..." + file.Name);
         // Get the input stream for the file
         using (IInputStream inStream = await file.OpenSequentialReadAsync())
         {
             // Deserialize the Session State
             DataContractSerializer serializer = new DataContractSerializer(objectType);
             obj = serializer.ReadObject(inStream.AsStreamForRead());
         }
         AppEventSource.Log.Debug("Suspension: Object loaded from file. " + objectType.ToString());
         // Delete the file
         if (deleteFile)
         {
             await file.DeleteAsync();
             deleteFile = false;
             AppEventSource.Log.Info("Suspension: File deleted. " + file.Name);
         }
         return obj;
     }
     catch (Exception e)
     {
         AppEventSource.Log.Error("Suspension: Error when deserializing object. Exception: " + e.Message);
         MessageDialog messageDialog = new MessageDialog("Error when deserializing App settings: " + file.Name + "\n" 
             + "The PDF file is not affected.\n " + "Details: \n" + e.Message);
         messageDialog.Commands.Add(new UICommand("Reset Settings", null, 0));
         messageDialog.Commands.Add(new UICommand("Ignore", null, 1));
         IUICommand command = await messageDialog.ShowAsync();
         switch ((int)command.Id)
         {
             case 0:
                 // Delete file
                 deleteFile = true;
                 break;
             default:
                 deleteFile = false;
                 break;
         }
         return null;
     }
     finally
     {
         // Delete the file if error occured
         if (deleteFile)
         {
             await file.DeleteAsync();
             AppEventSource.Log.Info("Suspension: File deleted due to error. " + file.Name);
         }
     }
 }
開發者ID:qiuosier,項目名稱:Libra,代碼行數:54,代碼來源:SuspensionManager.cs

示例4: PlayFile

	async Task PlayFile(StorageFile sf)
	{
		if (sf == null) {
			Exit();
			return;
		}
		byte[] module = new byte[ASAPInfo.MaxModuleLength];
		int moduleLen;
		using (IInputStream iis = await sf.OpenSequentialReadAsync()) {
			IBuffer buf = await iis.ReadAsync(module.AsBuffer(), (uint) ASAPInfo.MaxModuleLength, InputStreamOptions.None);
			moduleLen = (int) buf.Length;
		}

		ASAP asap = new ASAP();
		asap.Load(sf.Name, module, moduleLen);
		ASAPInfo info = asap.GetInfo();
		int song = info.GetDefaultSong();
		int duration = info.GetLoop(song) ? -1 : info.GetDuration(song);
		asap.PlaySong(song, duration);

		this.MyMedia = new MediaElement {
			AudioCategory = AudioCategory.BackgroundCapableMedia,
			Volume = 1,
			AutoPlay = true
		};
		Window.Current.Content = this.MyMedia;
		await Task.Yield();
		this.MyMedia.SetSource(new ASAPRandomAccessStream(asap, duration), "audio/x-wav");

		MediaControl.TrackName = info.GetTitleOrFilename();
		MediaControl.ArtistName = info.GetAuthor();
		MediaControl.PlayPressed += MediaControl_PlayPressed;
		MediaControl.PausePressed += MediaControl_PausePressed;
		MediaControl.PlayPauseTogglePressed += MediaControl_PlayPauseTogglePressed;
		MediaControl.StopPressed += MediaControl_StopPressed;
		MediaControl.IsPlaying = true;
	}
開發者ID:hudokkow,項目名稱:audiodecoder.asap,代碼行數:37,代碼來源:MetroASAP.cs


注:本文中的Windows.Storage.StorageFile.OpenSequentialReadAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。