Home » » C# — FileStream ile dosya okuma

C# — FileStream ile dosya okuma

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.IO;

namespace dosya_Okuma

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

public static byte[] dosya_Oku(string dosyaYolu)

{

byte[] buffer;

FileStream fs = new FileStream(dosyaYolu, FileMode.Open, FileAccess.Read);

try

{

int length = (int)fs.Length;

buffer = new byte[length];

int count;

int sum = 0;

while ((count = fs.Read(buffer, sum, length - sum)) > 0)

sum += count;

}

finally

{

fs.Close();

}

return buffer;

}

private void Form1_Load(object sender, EventArgs e)

{

string dosya = "c:/Vaganzi.txt";

dosya_Oku(dosya);

}

}

}
 
Support : Vaganzi
Copyright © 2013. Visual Studio Kod Bankası - All Rights Reserved
Powered By Vaganzi