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

c# open file

System.Diagnostics.Process.Start(filePath);
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 :: remove duplicate characters in a string c# 
Csharp :: mvc write to console 
Csharp :: speedtest.net cli 
Csharp :: c# datetime for filename 
Csharp :: .net mvc return a specific View 
Csharp :: set target framerate unity 
Csharp :: c# array of class 
Csharp :: increase value in dictionary against a key in c# 
Csharp :: c# public static string 
Csharp :: where in used in linq c# 
Csharp :: c# create array with n elements 
Csharp :: c# alphabetize a list of string 
Csharp :: save image in c# 
Csharp :: c# delete files in directory and subdirectories 
Csharp :: C# clear form 
Csharp :: how to concatenate two arrays in c# 
Csharp :: how to minimum text length in textbox in c# 
Csharp :: mvc refresh page from controller 
Csharp :: c# datagridview hide header 
Csharp :: how to iterate between hour range in c# 
Csharp :: unity render to texture2d 
Csharp :: c# yield 
Csharp :: which game engine is best 
Csharp :: c# color to console color 
Csharp :: finally c# code 
Csharp :: check if mouse is in frame unity 
Csharp :: unity agent look at 
Csharp :: c# object is in object list 
Csharp :: searching for keys in the registry 
Csharp :: join dictionaries keys c# 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =