FileStream question
Can anyone tell me hhow to get all files in the folder using filestream?
I tried using for statements to insert streams into an array of byte but it didnt work out
thx
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
John Donman3 pointsPosted Nov 16, 2005, 10:00 AM EST
Did you try Directory.GetFiles ?
phil ryan6 pointsPosted Nov 16, 2005, 8:23 PM EST
sunny23 pointsPosted Nov 22, 2005, 11:03 AM EST
FileStream fs;
BinaryReader r;
foreach(FileInfo file in Directory.GetFiles())
{
fs=new FileStream(file.FullName,FileMode.Open,FileAccess.Read);
r=new BinaryReader(fs);
byte[] bt=new byte[r.BaseStream.Length];
int ctr=0;
while(r.PeekChar() != -1)
{
bt[ctr]=r.ReadByte();
ctr++;
}
/*
Now you can use BinaryWriter to write the files into your own directory*/
//CHAO
}