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 ?
What I have for text (in Apl script ) :
sourceStream ← '.net' ⎕new 'System.IO.StreamReader' Localpathfilename encoding←'.NET' ⎕NEW 'System.Text.ASCIIEncoding'
I then lose bytes from the transferred binary file. I have also tried omitting the encoding line.
cheers, Beau
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
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
.....
Here is what I have now been trying, based on vb code at :
http://msdn.microsoft.com/en-us/library/system.io.file.openread#Y1035
Dim fs As FileStream
FileStream fs = File.OpenRead(path))
So I have tried :
fileStream ← '.net' ⎕new 'System.IO.File'
fileStream.OpenRead Localpathfilename
Here are the error messages :
Constructor on type 'System.IO.File' not found.
DOMAIN ERROR
net_ftp_putfile[72] fileStream←'.net' ⎕new 'System.IO.File'