xxxxxxxxxx
using System;
using System.IO;
namespace FileHandlinDemo
{
class Program
{
static void Main(string[] args)
{
string FilePath = @"D:\MyFile.txt";
string data;
FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read);
using (StreamReader streamReader = new StreamReader(fileStream))
{
data = streamReader.ReadToEnd();
}
Console.WriteLine(data);
Console.ReadLine();
}
}
}
xxxxxxxxxx
string text = File.ReadAllText(@"c:\file.txt", Encoding.UTF8);
xxxxxxxxxx
string[] lines = File.ReadAllLines(@"c:\file.txt", Encoding.UTF8);
xxxxxxxxxx
using(StreamReader file = new StreamReader(textFile)) {
int counter = 0;
string ln;
while ((ln = file.ReadLine()) != null) {
Console.WriteLine(ln);
counter++;
}
file.Close();
}
xxxxxxxxxx
using System;
using System.IO;
class Program
{
static void Main()
{
try
{
string path = "file.txt"; // Path to the file
// Read the contents of the file
string content = File.ReadAllText(path);
// Display the content
Console.WriteLine(content);
}
catch (Exception e)
{
Console.WriteLine("An error occurred: " + e.Message);
}
}
}
xxxxxxxxxx
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
xxxxxxxxxx
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
xxxxxxxxxx
sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin