Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 7 lis 2011 · While File.ReadAllLines() is one of the simplest ways to read a file, it is also one of the slowest. If you're just wanting to read lines in a file without doing much, according to these benchmarks, the fastest way to read a file is the age old method of: using (StreamReader sr = File.OpenText(fileName)) {.

  2. 11 lis 2021 · The recommended solution to read a file line by line is to use the File.ReadLines() method, which optionally takes a specific character encoding. The following code example demonstrates its usage to read the lines of a file.

  3. 19 gru 2023 · how to load a whole file to a single string. how to load a whole file to an array of strings, representing the lines of the file. how to load a file, line by line, in a lazy way, without compromising memory. Sometimes you don’t find what you’re looking for, and often the file you want to read isn’t there.

  4. 13 mar 2024 · File.ReadAllText reads the whole shebang in one go—great for smaller files. File.ReadAllLines gives you each line as an array element—handy for processing lines. StreamReader reads line-by-line, which is more memory efficient for big files.

  5. The following example uses the ReadLines method in a LINQ query that enumerates all directories for files that have a .txt extension, reads each line of the file, and displays the line if it contains the string "Microsoft".

  6. 24 lip 2024 · By utilizing classes like StreamReader and methods like File.ReadAllLines, you can easily read text files with minimal memory overhead and maximum efficiency. Start implementing these best practices in your C# projects to enhance file reading operations and improve overall application performance.

  7. 28 cze 2017 · if (File.Exists("file.txt")) { List<string[]> rows = File.ReadAllLines("file.txt").Select(x => x.Split(';')).ToList(); DataTable table = new DataTable(); table.Columns.Add(rows[0][0], typeof(string)); table.Columns.Add(rows[0][1], typeof(string)); table.Columns.Add(rows[0][2], typeof(int)); foreach (var row in rows.Skip(1)) { string fName = row ...

  1. Ludzie szukają również