Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>FileStream.Write</code> is basically what there is. It's <em>possible</em> that using a <code>BufferedStream</code> would help, but unlikely.</p> <p>If you're <em>really</em> reading a single line of text which, when encoded, is 500MB then I wouldn't be surprised to find that most of the time is being spent performing encoding. You should be able to test that by doing the encoding and then throwing away the result.</p> <p>Assuming the "encoding" you're performing is just <code>Encoding.GetBytes(string)</code>, you might want to try using a <code>StreamWriter</code> to wrap the <code>FileStream</code> - it may work better by tricks like repeatedly encoding into the same array before writing to the file.</p> <p>If you're actually reading a line <em>at a time</em> and appending that to the file, then:</p> <ul> <li><p>Obviously it's best if you keep both the input stream and output stream open throughout the operation. Don't repeatedly read and then write.</p></li> <li><p>You <em>may</em> get better performance using multiple threads or possibly asynchronous IO. This will partly depend on whether you're reading from and writing to the same drive.</p></li> <li><p>Using a <code>StreamWriter</code> is probably still a good idea.</p></li> </ul> <p>Additionally when creating the file, you <em>may</em> want to look at using a constructor which accepts a <a href="http://msdn.microsoft.com/en-us/library/system.io.fileoptions.aspx" rel="nofollow"><code>FileOptions</code></a>. Experiment with the available options, but I suspect you'll want <code>SequentialScan</code> and <em>possibly</em> <code>WriteThrough</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload