FTP upload + NAV2017

Javaid
Member Posts: 23
Hi
I want to upload *.csv files to a specifik ftp folder and I have found some code, that I do not understand. Can someone help me?
FTPSetup.SETRANGE("FTP Active",TRUE);
IF FTPSetup.FINDSET THEN
REPEAT
URL := FTPSetup."FTP Server" + ' ';
URL += FTPSetup."Path to Files"+'/' + 'de-int2c5-05012021.csv';
FTPRequest := WebRequest.Create(URL);
FTPRequest.Credentials := Credentials.NetworkCredential(FTPSetup."User ID",FTPSetup.Password);
FTPRequest.KeepAlive := FALSE;
FTPRequest.UseBinary := TRUE;
FTPRequest.Method := 'STOR';
FTPRequest.UsePassive := TRUE;
FileStream := FileA.OpenRead(FTPSetup."Path to Files"+'/' + 'de-int2c5-05012021.csv');
FTPRequest.GetRequestStream.Write(FileA.ReadAllBytes(FTPSetup."Path to Files"+'/' + 'de-int2c5-05012021.csv'), 0, FileStream.Length);
UNTIL FTPSetup.NEXT = 0;
Is the above code right to use to FTP upload?
Best Recards
Javaid
I want to upload *.csv files to a specifik ftp folder and I have found some code, that I do not understand. Can someone help me?
FTPSetup.SETRANGE("FTP Active",TRUE);
IF FTPSetup.FINDSET THEN
REPEAT
URL := FTPSetup."FTP Server" + ' ';
URL += FTPSetup."Path to Files"+'/' + 'de-int2c5-05012021.csv';
FTPRequest := WebRequest.Create(URL);
FTPRequest.Credentials := Credentials.NetworkCredential(FTPSetup."User ID",FTPSetup.Password);
FTPRequest.KeepAlive := FALSE;
FTPRequest.UseBinary := TRUE;
FTPRequest.Method := 'STOR';
FTPRequest.UsePassive := TRUE;
FileStream := FileA.OpenRead(FTPSetup."Path to Files"+'/' + 'de-int2c5-05012021.csv');
FTPRequest.GetRequestStream.Write(FileA.ReadAllBytes(FTPSetup."Path to Files"+'/' + 'de-int2c5-05012021.csv'), 0, FileStream.Length);
UNTIL FTPSetup.NEXT = 0;
Is the above code right to use to FTP upload?
Best Recards
Javaid
0
Best Answer
-
The path marked with green looks good
Active and passive:
Yes it can, it depends on the FTP server you can read more about active/passive here: https://www.jscape.com/blog/bid/80512/active-v-s-passive-ftp-simplifiedFor help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0
Answers
-
Perhaps this code can help you
This is code that can upload a file to a FTP site:FtpWebRequest := WebRequest.Create(FTPAdress + FileManagement.GetFileName(FullFilepath)); Credentials := Credentials.NetworkCredential(Username,Password); FtpWebRequest.Credentials := Credentials; FtpWebRequest.KeepAlive := FALSE; FtpWebRequest.UseBinary := TRUE; FtpWebRequest.UsePassive := Passiv; FtpWebRequest.Method('STOR'); FileStream := FileToUpload.OpenRead(FullFilepath); Stream := FtpWebRequest.GetRequestStream; Stream.Write(FileToUpload.ReadAllBytes(FullFilepath),0,FileStream.Length); Stream.Close; FtpWebResponse := FtpWebRequest.GetResponse; FileStream.Close; FtpWebRequest.Abort; //Get Status of Upload with //MESSAGE(FORMAT(FtpWebResponse.StatusDescription))
For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0 -
Hi
Thanks. I have some questions.
Mark with green: This is the full path to the file I will upload.
Mark with yellow: What is passive? Can it be false?
I will move the file to the FTP folder Mask_0295. Where do I mention this in the code?
0 -
The path marked with green looks good
Active and passive:
Yes it can, it depends on the FTP server you can read more about active/passive here: https://www.jscape.com/blog/bid/80512/active-v-s-passive-ftp-simplifiedFor help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0 -
Hi.
Could you please, tell me what king of variables are those used in this peace of code?
Thank you ever so much0 -
This problem is solved.
Thanks to everyone.0 -
Could you please, tell me what king of variables are those used in this peace of code?
FtpWebRequest@1160810003 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.FtpWebRequest"; WebRequest@1160810005 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.WebRequest"; Credentials@1160810004 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.NetworkCredential"; FileStream@1160810010 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.FileStream"; FileToUpload@1160810011 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File"; Stream@1160810001 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Stream"; FileManagement@1160810006 : Codeunit 419; FtpWebResponse@1160810012 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.FtpWebResponse";
For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0 -
Could you please, tell me what king of variables are those used in this peace of code?
FtpWebRequest@1160810003 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.FtpWebRequest"; WebRequest@1160810005 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.WebRequest"; Credentials@1160810004 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.NetworkCredential"; FileStream@1160810010 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.FileStream"; FileToUpload@1160810011 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File"; Stream@1160810001 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Stream"; FileManagement@1160810006 : Codeunit 419; FtpWebResponse@1160810012 : DotNet "'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.FtpWebResponse";
Thank you ever so much0 -
Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0 -
[Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions