FileStream ile dosya okuma C#
[code lang=”csharp”]
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:/gorselprogramlama.txt";
dosya_Oku(dosya);
}
}
}
[/code]
FileStream altı kırmızı neden böyle tanımlamam mı lazım yardım edin filestream filemode fileaccess hepsi kırmızı
berkay gündüz:
using (isim uzayı) bölümüne aşağıdaki kodu yazmamış olabilirsin.
using System.IO;
Merhaba benim bir sorunum var da 1 tane combobox , 3 tane textbox olacak dosya konumu , dosya adı , dosya uzantısı şeklinde comboboxta bulunan elemanların hepsini istediği dosya konumuna istediği dosya adı ve istediği dosya uzantısı şeklinde kaydedicek ama bir türlü dosyayı oluşturamıyorum bana yardımcı olabilir misiniz?