PDA

View Full Version : Hey, are you on my server?


Bruce
02-11-2009, 11:05 AM
This is part of my FTP up loader...

I need to check to see if there's anything in the "ftp" folder on my server, if there is, then a dialog comes up to say "sorry dude you can't upload yet".
The folder MUST be empty to upload to it.

Using the code below, how would I accomplish this?

result = FTP.ListFiles();
for i = 1, tbFiles.Count do
local name = tbFiles[i].Name;
err = Application.GetLastError();
if err ~= FTP.OK then
Dialog.Message("Error", _tblErrorMessages[err]);

ShadowUK
02-11-2009, 11:38 AM
This is part of my FTP up loader...

I need to check to see if there's anything in the "ftp" folder on my server, if there is, then a dialog comes up to say "sorry dude you can't upload yet".
The folder MUST be empty to upload to it.

Using the code below, how would I accomplish this?

result = FTP.ListFiles()
for i = 1, tbFiles.Count do
local name = tbFiles[i].Name;
err = Application.GetLastError();
if err ~= FTP.OK then
Dialog.Message("Error", _tblErrorMessages[err]);

Dunno where you're defining tbFiles, but I'd use

if (FTP.ListFiles().Count == 0) then
FTP.Upload("localfile.zip", "remotefile.zip", nil);
end