Skip to main content

ftp x++

str ftpHostName = 'ftp.microsoft.com'; // without "ftp://", only name
str username    = 'myloginname';
str password    = 'mypassword';
str oldname     = 'oldfilename';
str newname     = 'newfilename';

System.Net.Sockets.Socket socket;
System.Net.Dns dns;
System.Net.IPHostEntry  hostEntry;
System.Net.IPAddress[] addresses;
System.Net.IPAddress    address;
System.Net.IPEndPoint endPoint;

void sendCommand(str _command)
{
    System.Text.Encoding ascii;
    System.Byte[] bytes;
    ;

    ascii = System.Text.Encoding::get_ASCII();
    bytes = ascii.GetBytes(_command + '\r\n');
    socket.Send(bytes, bytes.get_Length(), System.Net.Sockets.SocketFlags::None);
}
;

socket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily::InterNetwork, System.Net.Sockets.SocketType::Stream, System.Net.Sockets.ProtocolType::Tcp);
hostEntry = System.Net.Dns::GetHostEntry(ftpHostName);

addresses = hostEntry.get_AddressList();
address = addresses.GetValue(0);

info(address.ToString());

endPoint = new System.Net.IPEndPoint(address, 21);
socket.Connect(endPoint);

sendCommand(strfmt("USER %1", username));
sendCommand(strfmt("PASS %1", password));
sendCommand(strfmt("RNFR %1", oldname));
sendCommand(strfmt("RNTO %1", newname));

Popular posts from this blog

Dynamics Axapta: Sales Orders & Business Connector

Well, again folllowing my same idea of writting close to nothing and pasting code, I'll paste in some code to create a sales order from some basic data and the invoice it. I'll try to explain more in the future. AxaptaObject axSalesTable = ax.CreateAxaptaObject("AxSalesTable"); AxaptaRecord rcInventDim = ax.CreateAxaptaRecord("InventDim"); AxaptaRecord rcCustTable = ax.CreateAxaptaRecord("CustTable"); rcCustTable.ExecuteStmt("select * from %1 where %1.AccountNum == '" + MySalesOrderObject.CustAccount + "'"); if (MySalesOrderObject.CurrencyCode.Trim().Length == 0) MySalesOrderObject.CurrencyCode = rcCustTable.get_Field("Currency").ToString().Trim(); string sTaxGroup = rcCustTable.get_Field("taxgroup").ToString().Trim(); //set header level fields axSalesTable.Call("parmSalesName", MySalesOrderObject.SalesName.Trim()); axSalesTable.Call("parmCustAccount", M

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() {    MenuFunction mf;    args args = new Args();    ;     args.record(EmplTable);     mf = new menufunction(identifierstr(EmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) {     EmplDuplication EmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }