I am trying to download ftp file. The following is a example reading one
file. My question is how to download all files(ex. *.txt) in the ftp folder.
Which method should I use?
BTW, when I use the WinAPI and WinInet, the function is working fine.
However, the task will be ran in batch in 64bit machine. It will cause a
exception error. Therefore, I need to try other solutions like this.
Thanks for your help in advance.
code:
System.Net.FtpWebRequest request;
System.Net.FtpWebResponse response;
System.Net.NetworkCredential credential;
Object ftpo;
ftpo = System.Net.WebRequest::Create("ftp://ftp.test.com/Readme.txt");
request = ftpo;
credential = new System.Net.NetworkCredential("username","passoword");
request.set_Credentials(credential);
request.set_Method("RETR");
response = request.GetResponse();
if (response)
info(response.get_StatusDescription());
please have look into this thread about ftp downloading.
http://social.msdn.microsoft.com/Forums/en/ncl/thread/079fb811-3c55-4959-85c4-677e4b20bea3
Hope this helps you.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Thanks for your help. This is very clear example. However, this is for .net,
not for x++.
For example, the following code is not supported in Axapta.
"reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;"
Probably it shoudl be wrote like below.
"request.set_Method("RETR");"
I have no idea what the exact code is and how to transfer such codes into
X++. Any idea?
Best regards,
Hike
you are right. A 1:1 translation form .NET Code (i.e. C#) to X++ Code is not
possible because of some differneces between the languages.
But the give code in the example should neerly work.
The only part you have to keep in mind are getter and setter.
In .NET getter and setter are implemented with only one method. In X++ this
is not possible.
In .NET you can use "reqFTP.Method = XZY" to set a value.
In X++ you must write "reqFTP.set_Method(XYZ)" to set a value.
But the MorphX Intellisense helps you with it.
To read the property you must use "reqFTP.get_Method ()" in X++.
Please take a look at http://msdn.microsoft.com/en-us/library/cc598160.aspx
for further details.
Sorry that i haven't an working example for you. But i think, after studying
the link above this will not be a hard job for you to make the .NET example
work in X++.