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
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
sunnyPosted Nov 22, 2005, 4:03 PM
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
}
phil ryanPosted Nov 17, 2005, 1:23 AM
John DonmanPosted Nov 16, 2005, 3:00 PM
Did you try Directory.GetFiles ?