Hi, everyone.
I have created an FTP upload function from within NAV using .NET, so that no external libs are needed for that.
Gladly sharing this with you (not optimized or anything, but works):
Now a question - I can't get my head around this:
The
FTPRequest.Method := 'STOR';
was my lucky guess, and every code sample I've seen actually says:
FTPRequest.Method := WebRequestMethods.Ftp.UploadFile;
As far as I understand, WebRequestMethods.Ftp is a .NET enumeration that in this case corresponds Strings.
How to use these enumerations appropriately?
Disclaimer: This is my first encounter with NAV+.NET
I have created an FTP upload function from within NAV using .NET, so that no external libs are needed for that.
Gladly sharing this with you (not optimized or anything, but works):
URL := 'ftp://remote_server/remote_folder/testfile.txt'; FTPRequest := WebRequest.Create(URL); Credentials := Credentials.NetworkCredential('some_login', 'some_password'); FTPRequest.Credentials := Credentials; FTPRequest.KeepAlive := false; FTPRequest.UseBinary := true; FTPRequest.Method := 'STOR'; FTPRequest.UsePassive := true; FileStream := FileA.OpenRead('c:\testfile.txt'); FTPRequest.GetRequestStream.Write(FileA.ReadAllBytes('c:\testfile.txt'), 0, FileStream.Length); --- WebRequest DotNet 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.WebRequest FTPRequest DotNet 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.FtpWebRequest Credentials DotNet 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.NetworkCredential FileStream DotNet 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.FileStream FileA DotNet 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File URL Text 250
Now a question - I can't get my head around this:
The
FTPRequest.Method := 'STOR';
was my lucky guess, and every code sample I've seen actually says:
FTPRequest.Method := WebRequestMethods.Ftp.UploadFile;
As far as I understand, WebRequestMethods.Ftp is a .NET enumeration that in this case corresponds Strings.
How to use these enumerations appropriately?
Disclaimer: This is my first encounter with NAV+.NET
