Hi
I have issues on how to "attack" this task.
I have to create a csv-file (either by creating a file and write to it or by a xml-port). This file I should upload to a ftp-address. The task has to be without any involvement - is started by an NAV-event.
The task is in two parts then.
1. Create a file in developer environment (temp-file???) - i don't have to use it afterwards
2. Transfer the file to an ftp-server
Again - the task is without any involvement from any person.
I have read and tried a lot, but seems to get stock. I'm used to working in the 2-tier environment and are not yet familiar with the 3-tier.
Does anyone has suggestions to this?
Regards
/Mads Morre
0
Answers
Then let your XMLPort export into that file using a stream.
For uploading the file onto the FTP there are several ways to do that.
The best, in my opinion is to just use .NET to do that.
Check out the FTPWebRequest class:
https://msdn.microsoft.com/en-us//library/system.net.ftpwebrequest(v=vs.110).aspx
Also there are plenty examples available online.
I tried this:
URL := parServer;
IF parFolder <> '' THEN
URL += parFolder+'/';
FTPRequest := WebRequest.Create(URL);
Credentials := Credentials.NetworkCredential(parUser,parPW);
FTPRequest.Credentials := Credentials;
FTPRequest.KeepAlive := FALSE;
FTPRequest.UseBinary := TRUE;
FTPRequest.Method := 'STOR';
FTPRequest.UsePassive := TRUE;
FileStream := FileA.OpenRead(parFileName);
FTPRequest.GetRequestStream.Write(FileA.ReadAllBytes(parFileName), 0, FileStream.Length);
Variables:
WebRequest DotNet System.Net.WebRequest.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
FTPRequest DotNet System.Net.FtpWebRequest.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Credentials DotNet System.Net.NetworkCredential.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
FileStream DotNet System.IO.FileStream.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
FileA DotNet System.IO.File.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
URL Text 250
But I get the following error - can you see why
try
URL += parFolder+'/';+ parFileName;
also check this for a full example from a recent thread
https://forum.mibuso.com/discussion/51988/ftp-upload-with-dotnet
https://dynamicsuser.net/nav/b/ara3n/posts/moving-files-in-nav-with-ftp
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I have solved the issue with a little help.
It is exactly as you wrote, Wisa123 - i needed the actual filename (to be) in the code as well.
Thansk for your replies.