Page 1 of 1

FTP: Creating a systematic directory with SyncFile function

Posted: March 6th, 2019, 6:36 am
by MarcOlivier
Hi everyone!
I'm facing a challenge in writing a code to create directory with SynvFile function
I would like in the directory it have been a folder named using the Date and time when the synchronization is made.
I think this was possible with de PNC file (%DateTime) so I wrote a similar code as bellow:

function SyncENQ1AvecQG()
if syncconnect(FTP,URLServer,Username,Pass) then
syncfile(PUT, "../App_Gouv/Gouvernance_MIC.csdb",
"/%Data_serveurENQ1%/%DateTime%/Gouvernance_MIC.csdb");

Buuut It doesn't work :(
I juste have a directory as : Data_serveurENQ1 ==> DateTime
instead of Data_serveurENQ1 ==> 060320191233 (for example)

What is wrong in my code ?

Re: FTP: Creating a systematic directory with SyncFile function

Posted: March 6th, 2019, 12:45 pm
by MarcOlivier
Hello Everyone

We (my colleague and I) have found a way to overcome the matter.

We have first create variables to get systematically date and hour in string format using edit() and sysdate() function. After we created an alphanum variable which is the concatenation of date and time making sure that /%; %/ symbols are at their rigth places. Then we use this alphanum from the concatenation as the to_path argument in the syncfile() function.

Maybe there exist a better way to do.
Opned to any other suggestions
Thanks

Re: FTP: Creating a systematic directory with SyncFile function

Posted: March 6th, 2019, 4:06 pm
by aaronw
Here's an example with sysdate and systime:
if syncfile(PUT, "/icon.png", edit("99999999", sysdate("YYYYDDMM")) + edit("9999", systime("HHMM")) + "/icon.png") then
However, if I just need a unique folder name, I prefer timestamp. If necessary I can always convert back to datetime:
if syncfile(PUT, "/icon.png", maketext("%d", timestamp()) + "/icon.png") then

Re: FTP: Creating a systematic directory with SyncFile function

Posted: March 8th, 2019, 4:23 pm
by MarcOlivier
Thank very much Aaronw for the input
I will try right now