我在 ftp 上发送 csv 文件时遇到问题,我使用在 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());
没有编译错误,没有执行错误但文件没有上传到我的 FTP 上,我认为问题出在路径文件编码上,我尝试了其他解决方案但没有结果。我想批量处理 FTP 上的发送文件,它使用 wininet 类工作,但 wininet 类不能在服务器端运行,所以我必须使用 .net 框架。欢迎任何想法或解决方案
感谢帮助