Skip to content

FileStream question

phil ryan

Asked Nov 16, 2005, 7:03 AM EST3 answers
Share
LinkedInX
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.

  • 0

    Did you try Directory.GetFiles ?

    0
  • 0
    iused directory.getfiles to get the filenames. The problem is i want to copy all of the folder contents using streams not usingfile.copyor directory.copy
    0
  • 0
    i am not sure but u can use this:


    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

    }

    0