System.IO.File.ReadLines C# (CSharp) Méthode

ReadLines() public static méthode

public static ReadLines ( String path ) : IEnumerable
path String
Résultat IEnumerable
        public static IEnumerable<String> ReadLines(String path)
        {
            if (path == null)
                throw new ArgumentNullException(nameof(path));
            if (path.Length == 0)
                throw new ArgumentException(SR.Argument_EmptyPath, nameof(path));
            Contract.EndContractBlock();

            return ReadLinesIterator.CreateIterator(path, Encoding.UTF8);
        }

Same methods

File::ReadLines ( String path, Encoding encoding ) : IEnumerable
File::ReadLines ( string path ) : System.Collections.Generic.IEnumerable
File::ReadLines ( string path, System encoding ) : System.Collections.Generic.IEnumerable

Usage Example

Exemple #1
0
        internal static void GetBMEInfo(string file)
        {
            var commands = new Dictionary <string, string>();

            foreach (var line in File.ReadLines(file))
            {
                if (!line.StartsWith("#"))
                {
                    continue;
                }

                var command = line.ToUpper().Substring(1).Split(" ").ToList();
                if (command.Count > 1)
                {
                    commands.Add(command[0], string.Join(" ", command.GetRange(1, command.Count - 1)));
                }
            }

            if (commands["PLAYER"] == "1")
            {
                SongInfo songInfo = new SongInfo();
                songInfo.Artist     = commands["ARTIST"];
                songInfo.BPM        = float.Parse(commands["BPM"]);
                songInfo.Difficulty = (Difficulty)int.Parse(commands["DIFFICULTY"]);
                songInfo.Genre      = commands["GENRE"];
                songInfo.Path       = file;
                songInfo.PlayLevel  = byte.Parse(commands["PLAYLEVEL"]);
                songInfo.Title      = commands["TITLE"];
                songInfo.Total      = float.Parse(commands["TOTAL"]);

                Songs.Add(songInfo);
            }
        }
All Usage Examples Of System.IO.File::ReadLines