<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.twig.es/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Reading_a_file_using_filestream_in_csharp</id>
		<title>Reading a file using filestream in csharp - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Reading_a_file_using_filestream_in_csharp"/>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Reading_a_file_using_filestream_in_csharp&amp;action=history"/>
		<updated>2026-05-06T18:24:24Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.0</generator>

	<entry>
		<id>https://wiki.twig.es/index.php?title=Reading_a_file_using_filestream_in_csharp&amp;diff=1780&amp;oldid=prev</id>
		<title>George2: Created page with &quot;&lt;source lang=&quot;csharp&quot;&gt; using System.IO;  public static byte[] ReadFile(string filePath) {   byte[] buffer;   FileStream fileStream = new FileStream(filePath, FileMode.Open, Fi...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Reading_a_file_using_filestream_in_csharp&amp;diff=1780&amp;oldid=prev"/>
				<updated>2015-03-27T21:45:34Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; using System.IO;  public static byte[] ReadFile(string filePath) {   byte[] buffer;   FileStream fileStream = new FileStream(filePath, FileMode.Open, Fi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System.IO;&lt;br /&gt;
&lt;br /&gt;
public static byte[] ReadFile(string filePath)&lt;br /&gt;
{&lt;br /&gt;
  byte[] buffer;&lt;br /&gt;
  FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);&lt;br /&gt;
  try&lt;br /&gt;
  {&lt;br /&gt;
    int length = (int)fileStream.Length;  // get file length&lt;br /&gt;
    buffer = new byte[length];            // create buffer&lt;br /&gt;
    int count;                            // actual number of bytes read&lt;br /&gt;
    int sum = 0;                          // total number of bytes read&lt;br /&gt;
&lt;br /&gt;
    // read until Read method returns 0 (end of the stream has been reached)&lt;br /&gt;
    while ((count = fileStream.Read(buffer, sum, length - sum)) &amp;gt; 0)&lt;br /&gt;
      sum += count;  // sum is a buffer offset for next reading&lt;br /&gt;
  }&lt;br /&gt;
  finally&lt;br /&gt;
  {&lt;br /&gt;
    fileStream.Close();&lt;br /&gt;
  }&lt;br /&gt;
  return buffer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>George2</name></author>	</entry>

	</feed>