I have problems to send csv file on ftp, I use the following code found on AxaptaPedia:
object ftpo;
object ftpResponse;
System.Net.FtpWebRequest request;
System.IO.StreamReader reader;
System.IO.Stream requestStream;
System.Byte[] bytes;
System.Net.NetworkCredential credential;
System.String xmlContent;
System.Text.Encoding utf8;
System.Net.FtpWebResponse response;
;
reader = new System.IO.StreamReader(strfmt("%1%2","\\\\Server\\directory\\","Export.csv"));
utf8 = System.Text.Encoding::get_UTF8();
bytes = utf8.GetBytes( reader.ReadToEnd() );
reader.Close();
ftpo = System.Net.WebRequest::Create(strfmt("%1%2","ftp://IP_Address/directory/","Export.csv"));
request = ftpo;
credential = new System.Net.NetworkCredential("user","password");
request.set_Credentials(credential);
request.set_ContentLength(bytes.get_Length());
request.set_Method("STOR");
requestStream = request.GetRequestStream();
requestStream.Write(bytes,0,bytes.get_Length());
requestStream.Close();
ftpResponse = request.GetResponse();
response = ftpResponse;
info(response.get_StatusDescription());
No compilation errors, no execution errors but file is not uploaded on my FTP, I think the problem is on the path file coding, i tried other solutions without results. I want to process send file on FTP in batch, it works using wininet class but wininet class can't be run on server side so I must use .net framework. Any ideas or solution is welcome
thanks for help