title: How do I set the encoding for a .net binary file transfer
body: <p>I can successfully upload text files using .net ftp
   but now want to upload a graphics (.png) image.
  How should I set the stream encoding ?</p>
  
  <p>What I have for text (in Apl script ) :</p>
  
  <p>sourceStream ← '.net' ⎕new 'System.IO.StreamReader' Localpathfilename
  encoding←'.NET' ⎕NEW 'System.Text.ASCIIEncoding'</p>
  
  <p>I then lose bytes from the transferred binary file.
  I have also tried omitting the encoding line.</p>
  
  <p>cheers, Beau</p>
  
  <p>More info :
  This is the core of the Ascii version, written in AplX .net - 
  It works fine 
  - now I need a BinaryReader version.
  Help appreciated</p>
  
  <pre><code>  ftp←'.net' ⎕call 'System.Net.WebRequest.Create' Remotepathfilename
    ftp.Method←'.net' ⎕call 'System.Net.WebRequestMethods+Ftp.UploadFile'
    ftp.Credentials←'.net' ⎕new 'System.Net.NetworkCredential' Username Password
  
  sourceStream ← '.net' ⎕new 'System.IO.StreamReader' Localpathfilename
  encoding←'.NET' ⎕NEW 'System.Text.ASCIIEncoding'
  
  fileContents ← encoding.GetBytes.⎕REF 
  sourceStream.ReadToEnd 
  sourceStream.Close 
  ftp.ContentLength ← fileContents.Length 
  :try
    stream←ftp.GetRequestStream
  :catchall
    .....
  </code></pre>
  
  <p>Here is what I have now been trying, based on vb code at :</p>
  
  <pre><code>http://msdn.microsoft.com/en-us/library/system.io.file.openread#Y1035
  
  Dim fs As FileStream
  FileStream fs = File.OpenRead(path))
  </code></pre>
  
  <p>So I have tried :</p>
  
  <pre><code>fileStream ← '.net' ⎕new 'System.IO.File' 
  fileStream.OpenRead  Localpathfilename
  </code></pre>
  
  <p>Here are the error messages :</p>
  
  <pre><code>Constructor on type 'System.IO.File' not found.
  DOMAIN ERROR
  net_ftp_putfile[72] fileStream←'.net' ⎕new 'System.IO.File'
  </code></pre>