Read and Write Memory c# Files Please
using System.IO;
// Create a MemoryStream object
using (MemoryStream memoryStream = new MemoryStream())
{
// Create a StreamWriter object to write to the memory stream
using (StreamWriter writer = new StreamWriter(memoryStream))
{
// Write some text to the memory stream
writer.WriteLine("Hello, world!");
}
// Get the bytes from the memory stream
byte[] bytes = memoryStream.ToArray();
// Do something with the bytes, such as write them to a file
File.WriteAllBytes("output.txt", bytes);
}
using System.IO;
// Read the contents of a file into a byte array
byte[] bytes = File.ReadAllBytes("input.txt");
// Create a MemoryStream object from the byte array
using (MemoryStream memoryStream = new MemoryStream(bytes))
{
// Create a StreamReader object to read from the memory stream
using (StreamReader reader = new StreamReader(memoryStream))
{
// Read the contents of the memory stream
string text = reader.ReadToEnd();
// Do something with the text
Console.WriteLine(text);
}
}
nasıl kullanıldığı öğretecek bir video var mıthank you for