Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: System.IO.FileStream

$
0
0

There are many ways to do this but a simple way would be to use the Read method to handle the entire file in a single operation instead of a byte at a time.

Example:

          declare ws-cFileStream as type FileStream = new FileStream("mydata.txt", type FileMode::Open, type FileAccess::Read)
          invoke ws-cFileStream::Seek(0, type SeekOrigin::Begin)
          declare bytes as binary-char unsigned occurs any
          set size of bytes to ws-cFileStream::Length
          invoke ws-cFileStream::Read(bytes, 0, ws-cFileStream::Length)
          declare textfield as string = type System.Text.Encoding::Default::GetString(bytes)


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>