Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. System.io.FileStream

System.io.FileStream

Scheduled Pinned Locked Moved C#
question
6 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cmarmr
    wrote on last edited by
    #1

    how do i tell if my filestream is at the end of the file char[] holder=new char[256]; FileStream fs=new FileStream("c:\\temp.txt",FileAccessmode.Read) while ()//don know what to put there { fs.read(holder,0,256) } thanks chad

    H W T 3 Replies Last reply
    0
    • C cmarmr

      how do i tell if my filestream is at the end of the file char[] holder=new char[256]; FileStream fs=new FileStream("c:\\temp.txt",FileAccessmode.Read) while ()//don know what to put there { fs.read(holder,0,256) } thanks chad

      H Offline
      H Offline
      Henrik Stuart
      wrote on last edited by
      #2

      while (fs.Position < fs.Length)

      for instance. -- Henrik Stuart (http://www.unprompted.com/hstuart/)

      1 Reply Last reply
      0
      • C cmarmr

        how do i tell if my filestream is at the end of the file char[] holder=new char[256]; FileStream fs=new FileStream("c:\\temp.txt",FileAccessmode.Read) while ()//don know what to put there { fs.read(holder,0,256) } thanks chad

        W Offline
        W Offline
        Werdna
        wrote on last edited by
        #3

        while (fs.read(holder,0,256) > 0) { }

        L 1 Reply Last reply
        0
        • C cmarmr

          how do i tell if my filestream is at the end of the file char[] holder=new char[256]; FileStream fs=new FileStream("c:\\temp.txt",FileAccessmode.Read) while ()//don know what to put there { fs.read(holder,0,256) } thanks chad

          T Offline
          T Offline
          Tom Larsen
          wrote on last edited by
          #4

          You can do it in loop and out of loop by checking to see if Stream.Length is equal to Stream.Position or checking the return value of Stream.Read/Byte for 0.

          1 Reply Last reply
          0
          • W Werdna

            while (fs.read(holder,0,256) > 0) { }

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            >= 0 :) top secret

            J 1 Reply Last reply
            0
            • L leppie

              >= 0 :) top secret

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #6

              FileStream.Read will return 0 when it gets to the end of the stream so you should test for the return value being > 0 and exit the loop on it being == 0. James

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups