当前位置: 首页>>代码示例>>C#>>正文


C# IStorageFile.OpenStreamForReadAsync方法代码示例

本文整理汇总了C#中IStorageFile.OpenStreamForReadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IStorageFile.OpenStreamForReadAsync方法的具体用法?C# IStorageFile.OpenStreamForReadAsync怎么用?C# IStorageFile.OpenStreamForReadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IStorageFile的用法示例。


在下文中一共展示了IStorageFile.OpenStreamForReadAsync方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseAsync

        public async Task<Issue> ParseAsync(IStorageFile issueFolioFile, string pathPrefix)
        { 
            Issue issue = new Issue(pathPrefix);
            
            Stream stream = await issueFolioFile.OpenStreamForReadAsync();

            XmlReader reader = XmlReader.Create(stream);
            if (reader != null)
            {
                // setting up the cover images assumed to be in the root folio folder
                issue.LandscapeImageUrl = "/cover_h.png";
                issue.PortraitImageUrl = "/cover_v.png";

                while (reader.Read())
                {
                    if (reader.NodeType != XmlNodeType.EndElement)
                    {
                        switch (reader.Name)
                        {
                            case "folio":
                                //issue.RelativePath = Repository.GetIssueRelativePath(issue.Id);
                                issue.Date = reader.GetAttribute("date");
                                break;
                            case "magazineTitle":
                                reader.Read();
                                issue.Id = reader.Value.ToLower().Replace(" ", "") + "_";
                                issue.DisplayName = reader.Value;
                                break;
                            case "folioNumber":
                                reader.Read();
                                issue.Id += reader.Value.ToLower().Replace(" ", "");
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            return issue;
        }
开发者ID:KurtisDahl,项目名称:FolioParser,代码行数:40,代码来源:IssueFolioParser.cs

示例2: Load

		public async Task<BatNodeLog> Load(IStorageFile file)
		{
			BatNodeLog log = new BatNodeLog();
			log.LogStart = DateTime.UtcNow;
			using (Stream logStream = await file.OpenStreamForReadAsync())
			{
				using (BinaryReader reader = new BinaryReader(logStream))
				{
					ReadData(log, reader);
				}
			}
			log.CallCount = log.Calls.Count;
			return log;
		}
开发者ID:mjeanrichard,项目名称:TeensyBat,代码行数:14,代码来源:BatNodeLogReader.cs

示例3: GetImageKey

        /// <summary>
        /// 
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private async Task<string> GetImageKey(IStorageFile file)
        {
            var key = default(string);

            using (var fileStream = await file.OpenStreamForReadAsync())
            {
                var bytes = Core2D.Project.ReadBinary(fileStream);
                key = _context.Editor.Project.AddImageFromFile(file.Path, bytes);
            }

            return key;
        }
开发者ID:hacklex,项目名称:Core2D,代码行数:17,代码来源:MainPage.xaml.cs

示例4: HandleFilePickerLaunch

        internal async void HandleFilePickerLaunch(IStorageFile pickedFile)
        {
            if (!IsNoSyncInProgress) return;

            CurrentAction = ActionType.ImportStats;

            StatImportSongsFound = 0;
            StatImportSongsSkipped = 0;

            using (Stream stream = await pickedFile.OpenStreamForReadAsync())
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();

                        string[] parts = line.Split(new char[] { '|' });

                        if (parts.Count() == 6)
                        {
                            string TrackName = parts[0];
                            string AlbumName = parts[1];
                            string ArtistName = parts[2];
                            string Rating = parts[3];
                            string PlayCount = parts[4];
                            string LastPlayed = parts[5];

                            SongViewModel song = LibraryViewModel.Current.LookupSongByName(TrackName, ArtistName);

                            if (song != null)
                            {
                                song.Rating = uint.Parse(Rating);

                                // TODO: let user toggle this
                                song.PlayCount = uint.Parse(PlayCount);

                                DateTime realLastPlayed = new DateTime(long.Parse(LastPlayed));

                                if (song.LastPlayed < realLastPlayed)
                                {
                                    song.LastPlayed = realLastPlayed;
                                }

                                StatImportSongsFound++;
                            }
                            else
                            {
                                StatImportSongsSkipped++;
                            }
                        }
                    }
                }
            }

            CurrentAction = ActionType.None;
        }
开发者ID:jevonsflash,项目名称:ProjectMato,代码行数:57,代码来源:MediaImportManager.cs

示例5: OpenStreamForReadAsync

 public static async Task<Stream> OpenStreamForReadAsync(IStorageFile windowsRuntimeFile)
 {
     try
     {
         return await windowsRuntimeFile.OpenStreamForReadAsync();
     }
     catch { return null; }
 }
开发者ID:ranjittgs,项目名称:MyExpenses,代码行数:8,代码来源:AppStorage.cs

示例6: ReadLinesAsync

        /// <summary>
        /// Reads the contents of the specified file using the specified character encoding and returns lines of text.
        /// </summary>
        /// <param name="file">The file to read.</param>
        /// <param name="encoding">The character encoding of the file.</param>
        /// <returns>When this method completes successfully, it returns the contents of the file as a list (type IVector) of lines of text.
        /// Each line of text in the list is represented by a String object.</returns>
        public static Task<IList<string>> ReadLinesAsync(IStorageFile file, UnicodeEncoding encoding)
        {
#if __ANDROID__ || __IOS__ || __TVOS__ || WIN32 || TIZEN
            return PathIO.ReadLinesAsync(file.Path, encoding);
#elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81
            return Windows.Storage.FileIO.ReadLinesAsync((Windows.Storage.StorageFile)((StorageFile)file), (Windows.Storage.Streams.UnicodeEncoding)((int)encoding)).AsTask();
#elif WINDOWS_PHONE
            return Task.Run<IList<string>>(async () =>
            {
                String line;
                List<String> lines = new List<String>();

                Stream s = await file.OpenStreamForReadAsync();
                using (StreamReader sr = new StreamReader(s, UnicodeEncodingHelper.EncodingFromUnicodeEncoding(encoding)))
                    while ((line = sr.ReadLine()) != null)
                        lines.Add(line);

                return lines.ToArray();
            });
#else
            throw new PlatformNotSupportedException();
#endif
        }
开发者ID:inthehand,项目名称:Charming,代码行数:30,代码来源:FileIO.cs

示例7: getPhotoReadStreamAsync

 private async Task<Stream> getPhotoReadStreamAsync(IStorageFile file)
 {
     return await file.OpenStreamForReadAsync();
 }
开发者ID:Astralius,项目名称:Patronage2016-Windows,代码行数:4,代码来源:Photo.cs

示例8: ImportPathfinderSpellsCSV

        private async void ImportPathfinderSpellsCSV(IStorageFile file)
        {

            using (var reader = new StreamReader(await file.OpenStreamForReadAsync()))
            {
                var csvHelper = new CsvHelper.CsvReader(reader);
                var spells = csvHelper.GetRecords<PathfinderSpellsCSV>();
                foreach(var spell in spells)
                {
                    //spell.
                }
                
            }

        }
开发者ID:coreystruble,项目名称:RPG-Character-Scry,代码行数:15,代码来源:LoadViewModel.cs

示例9: LoadTransmissionFromFileAsync

 private static async Task<StorageTransmission> LoadTransmissionFromFileAsync(IStorageFile file)
 {
     try
     {
         using (Stream stream = await file.OpenStreamForReadAsync().ConfigureAwait(false))
         {
             StorageTransmission storageTransmissionItem = await StorageTransmission.CreateFromStreamAsync(stream, file.Path).ConfigureAwait(false);
             return storageTransmissionItem;
         }
     }
     catch (Exception e)
     {
         string message = string.Format("Failed to load transmission from file. File path: {0}, FileName: {1}, Exception: {2}", file.Path, file.Name, e);
         CoreEventSource.Log.LogVerbose(message);
         throw;
     }
 }
开发者ID:iusafaro,项目名称:ApplicationInsights-dotnet,代码行数:17,代码来源:Storage.cs


注:本文中的IStorageFile.OpenStreamForReadAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。