Read and Write Memory c#

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Matrix
Onaylı Üye
Katılım
1 Mar 2023
Mesajlar
55
Tepki puanı
5
Ödüller
2
3 HİZMET YILI
Read and Write Memory c# Files Please
 
ölmedim geri döndüm kaldığımız yerden devam
Süper Üye
Katılım
6 Eki 2019
Mesajlar
744
Çözümler
19
Tepki puanı
155
Ödüller
6
Sosyal
6 HİZMET YILI
Read and Write Memory c# Files Please
Kod:
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);
}
Kod:
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);
    }
}
 
Onaylı Üye
Katılım
12 Mar 2023
Mesajlar
54
Tepki puanı
3
Ödüller
1
Yaş
26
3 HİZMET YILI
Nasıl kullanicaz bunu ki bilen varmı
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...