Hello to everyone,
I am using the ftp plugin to upload some files to my host. The files are uploaded if directories depending of the upload date.
The issue is here: I create this structure to upload the files.
rootpath/year/month/date
When the structure is generated for the first time everything works well, but than it gives and error because the directories exist and can't be created twice.
The code that I use is this
How can I check if a directory exist before I create a new one?!
I am using the ftp plugin to upload some files to my host. The files are uploaded if directories depending of the upload date.
The issue is here: I create this structure to upload the files.
rootpath/year/month/date
When the structure is generated for the first time everything works well, but than it gives and error because the directories exist and can't be created twice.
The code that I use is this
Code:
FTP.MakeDir(System.GetDate(DATE_FMT_YEAR)); err = Application.GetLastError(); if err ~= FTP.OK then Dialog.Message("Error", _tblErrorMessages[err]); Application.ExitScript(); else FTP.ChangeDir(System.GetDate(DATE_FMT_YEAR)); err = Application.GetLastError(); if err ~= FTP.OK then Dialog.Message("Error", _tblErrorMessages[err]); Application.ExitScript(); else FTP.MakeDir(System.GetDate(DATE_FMT_MONTH)); err = Application.GetLastError(); if err ~= FTP.OK then Dialog.Message("Error", _tblErrorMessages[err]); Application.ExitScript(); else FTP.ChangeDir(System.GetDate(DATE_FMT_MONTH)); err = Application.GetLastError(); if err ~= FTP.OK then Dialog.Message("Error", _tblErrorMessages[err]); Application.ExitScript(); else FTP.MakeDir(System.GetDate(DATE_FMT_DAY)); err = Application.GetLastError(); if err ~= FTP.OK then Dialog.Message("Error", _tblErrorMessages[err]); Application.ExitScript(); else FTP.ChangeDir(System.GetDate(DATE_FMT_DAY)); err = Application.GetLastError(); end end end end end
Comment