Показать сообщение отдельно
Старый 19.05.2009, 22:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
axaptapedia: FtpWebRequest
Источник: http://www.axaptapedia.com/FtpWebRequest
==============

Summary: New page: Since version 4 and in version 2009 you may use the .NET framework inside Dynamics AX. The FtpWebRequest class in the System.Net namespace handles FTP communication like upload, download, ...

Since version 4 and in version 2009 you may use the .NET framework inside Dynamics AX. The FtpWebRequest class in the System.Net namespace handles FTP communication like upload, download, delete files and retrieve a list of files in a directory, etc.

==Upload File==

X++:
static void uploadTestFile(Args _args)
{
    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;
    ;

    // Read file
    reader = new System.IO.StreamReader("C:/test.xml");
    utf8 = System.Text.Encoding::get_UTF8();
    bytes = utf8.GetBytes( reader.ReadToEnd() );
    reader.Close();

    // little workaround to get around the casting in .NET
    ftpo = System.Net.WebRequest::Create("ftp://ftp.company.com/dir/test.xml");
    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());
}
[[Category:.NET Development]]


Источник: http://www.axaptapedia.com/FtpWebRequest
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.