Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

read file c#

string text = File.ReadAllText(@"c:file.txt", Encoding.UTF8);
Comment

c# read from file

string[] lines = File.ReadAllLines(@"c:file.txt", Encoding.UTF8);
Comment

read file c#


string contents = File.ReadAllText(@"C:	emp	est.txt");

Comment

c# read file

using System;
using System.IO;
 
public class Example
{
    public static void Main()
    {
        string fileName = @"C:examplepath.txt";
 
        using (StreamReader streamReader = File.OpenText(fileName))
        {
            string text = streamReader.ReadToEnd();
            string[] lines = text.Split(Environment.NewLine);
 
            foreach (string line in lines) {
                Console.WriteLine(line);
            }
        }
    }
}
Comment

Read file using c#

 		/// 08/04/2022 Mahesh Kumar Yadav. <br/>
        /// <summary>
        /// Read file and split line one by one
        /// </summary>
        internal static void ReadFileAndSplitByLine(string filePath)
        {
            using (var streamReader = File.OpenText(filePath))
            {
                var text = streamReader.ReadToEnd();
                var lines = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                foreach (var line in lines)
                {
                    Console.WriteLine(line);
                }
            }
        }
Comment

c# file read

using(StreamReader file = new StreamReader(textFile)) {  
 int counter = 0;  
 string ln;  
  
 while ((ln = file.ReadLine()) != null) {  
  Console.WriteLine(ln);  
  counter++;  
 }  
 file.Close();  
} 
Comment

PREVIOUS NEXT
Code Example
Csharp :: write line to file c# 
Csharp :: unity show colliders 
Csharp :: unity check if other object is colliding 
Csharp :: c# get datatable column names to list 
Csharp :: const class in c sharp 
Csharp :: serilog set log level 
Csharp :: c# print console 
Csharp :: unity random number 
Csharp :: c# how to sort a list 
Csharp :: linq where id in list 
Csharp :: switch case c# 
Csharp :: move files from one directory to another using c# 
Csharp :: .net mvc decimal displayformat currency 
Csharp :: unity stop animation from playing at start 
Csharp :: httpwebrequest c# example 
Csharp :: unity round float to nearest 10 
Csharp :: unity cast int to float 
Csharp :: how to make colliders collide with some things but not other in unity 
Csharp :: c# new object without class 
Csharp :: c# how to fill a datatable 
Csharp :: ef core set identity_insert off 
Csharp :: c# string code ascii 
Csharp :: count number of properties on an object C# 
Csharp :: dicionário c# foreach keyvaluepair 
Csharp :: build cs file 
Csharp :: c# convert list t to datatable 
Csharp :: lcm of numbers 
Csharp :: c# get excel column number from letter 
Csharp :: unity 2d 
Csharp :: ternary operator in c# 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =