Hi,
I am retrieving a file and sending it through FTP but norwegian char(ø å æ) does not work.
used .NET in x++.
Most probably the problem is in the function get_UTF8() .I tried other function too but nothing is working.
reader = new System.IO.StreamReader(localFileNameAndPath);
utf8 = System.Text.Encoding::get_UTF8();
fileContent = utf8.GetBytes(reader.ReadToEnd());
server static boolean putFileToServer(AHL_eduTransportSpesification transSpec, str localFileNameAndPath, str serverFileName)
{
boolean fileOK = true;
object ftpRequest;
object ftpResponse;
System.IO.StreamWriter TextWriter;
System.IO.StreamReader reader;
System.IO.Stream requestStream;
System.Net.FtpWebRequest request;
System.Net.FileWebResponse response;
System.Net.NetworkCredential credential;
System.Exception ex;
InteropPermission perm;
FileIOPermission IOPerm;
System.Byte[] fileContent;
ASCIIIO fileOut,fileInn;
System.Text.Encoding utf8;
Container con;
str s;
int num;
str ch;
;
perm = new InteropPermission(InteropKind::ClrInterop);
perm.assert();
reader = new System.IO.StreamReader(localFileNameAndPath);
utf8 = System.Text.Encoding::get_UTF8();
fileContent = utf8.GetBytes(reader.ReadToEnd());
reader.Close();
CodeAccessPermission::revertAssert();
perm = new InteropPermission(InteropKind::ClrInterop);
perm.assert();
try
{
ftpRequest = System.Net.WebRequest::Create("ftp://" + transSpec.FTPServerName + "/" + transSpec.FTPDirectory + "/" + serverFileName );
request = ftpRequest; // Eneste måte å omgå casting på.
credential = new System.Net.NetworkCredential(transSpec.FTPUserName, transSpec.FTPPassword);
request.set_Credentials(credential);
request.set_ContentLength(fileContent.get_Length());
request.set_Method("STOR");
requestStream = request.GetRequestStream();
requestStream.Write(fileContent,0,fileContent.get_Length());
requestStream.Close();
ftpResponse = request.GetResponse();
response = ftpResponse;
}
catch (Exception::CLRError)
{
ex = CLRInterop::getLastException().GetBaseException();
error(ex.get_Message());
}
CodeAccessPermission::revertAssert();
return fileOK;
}
*This post is locked for comments