SteveStation
04-25-2007, 05:23 AM
http://www.indigorose.com/forums/showthread.php?t=13133
i am using this ftp sample but i have a problem i think the solutions is simple but i dont findit. i want to the comand Dialog.FileBrowse open the file automatic to i dont nedd to press open and i dont want that the mesage apear, (File Already Exists!", "Overwrite the existing file) i want to replace the file automatic
if FTP.IsConnected() then
-- ask the user to browse for a file
tbFiles = Dialog.FileBrowse(true, "Select File to Upload", "C:\\fttp\\test", "All Files (*.*)|*.*|", "test.txt", "", false, true)
-- check for an error
if tbFiles == nil then
-- an error occurred
err = Application.GetLastError();
Dialog.Message("Error", _tblErrorMessages[err], MB_OK, MB_ICONEXCLAMATION);
else
-- no error...
-- did the user cancel out of the dialog?
if tbFiles[1] ~= "CANCEL" then
-- they didn't cancel...we should have a file in the table
-- we can assume it's the first item since we set MultipleSelection to false
-- in the Dialog.FileBrowse action
strSourceFile = tbFiles[1];
-- split the file path into its various parts (path, filename, extension, etc.)
tbPathParts = String.SplitPath(strSourceFile);
-- ...now build a filename out of the parts
strDestFile = tbPathParts.Filename..tbPathParts.Extension;
-- flag to control whether to go through with the upload ("My Kingdom for a break command!")
local bUpload = true;
-- does the remote file already exist?
if FTP.GetFileInfo(strDestFile) ~= true then
-- destination file already exists, ask the user if it's ok to replace it
local nResult = Dialog.Message("File Already Exists!", "Overwrite the existing file?", MB_OKCANCEL, MB_ICONQUESTION, MB_DEFBUTTON1);
if nResult == IDCANCEL then
-- user pressed cancel
bUpload = false;
end
end
if bUpload then
-- show the status dialog and enable the cancel button
StatusDlg.ShowCancelButton();
StatusDlg.Show();
-- upload the file
FTP.Upload(strSourceFile, strDestFile);
err = Application.GetLastError();
-- hide the status dialog
StatusDlg.Hide();
if err == FTP.OK then
-- update the directory list
UpdateList();
else
-- FTP.Upload error!
-- append the error message to the log
Paragraph.SetText("Log_paragraph", Paragraph.GetText("Log_paragraph").."* Error: " .. _tblErrorMessages[err] .."\r\n");
end
end
end
end
else
-- not connected
Dialog.Message("Not Connected", "You must connect to an FTP server before you can upload a file.", MB_OK, MB_ICONEXCLAMATION);
end
Im sory for my bad ingles
i am using this ftp sample but i have a problem i think the solutions is simple but i dont findit. i want to the comand Dialog.FileBrowse open the file automatic to i dont nedd to press open and i dont want that the mesage apear, (File Already Exists!", "Overwrite the existing file) i want to replace the file automatic
if FTP.IsConnected() then
-- ask the user to browse for a file
tbFiles = Dialog.FileBrowse(true, "Select File to Upload", "C:\\fttp\\test", "All Files (*.*)|*.*|", "test.txt", "", false, true)
-- check for an error
if tbFiles == nil then
-- an error occurred
err = Application.GetLastError();
Dialog.Message("Error", _tblErrorMessages[err], MB_OK, MB_ICONEXCLAMATION);
else
-- no error...
-- did the user cancel out of the dialog?
if tbFiles[1] ~= "CANCEL" then
-- they didn't cancel...we should have a file in the table
-- we can assume it's the first item since we set MultipleSelection to false
-- in the Dialog.FileBrowse action
strSourceFile = tbFiles[1];
-- split the file path into its various parts (path, filename, extension, etc.)
tbPathParts = String.SplitPath(strSourceFile);
-- ...now build a filename out of the parts
strDestFile = tbPathParts.Filename..tbPathParts.Extension;
-- flag to control whether to go through with the upload ("My Kingdom for a break command!")
local bUpload = true;
-- does the remote file already exist?
if FTP.GetFileInfo(strDestFile) ~= true then
-- destination file already exists, ask the user if it's ok to replace it
local nResult = Dialog.Message("File Already Exists!", "Overwrite the existing file?", MB_OKCANCEL, MB_ICONQUESTION, MB_DEFBUTTON1);
if nResult == IDCANCEL then
-- user pressed cancel
bUpload = false;
end
end
if bUpload then
-- show the status dialog and enable the cancel button
StatusDlg.ShowCancelButton();
StatusDlg.Show();
-- upload the file
FTP.Upload(strSourceFile, strDestFile);
err = Application.GetLastError();
-- hide the status dialog
StatusDlg.Hide();
if err == FTP.OK then
-- update the directory list
UpdateList();
else
-- FTP.Upload error!
-- append the error message to the log
Paragraph.SetText("Log_paragraph", Paragraph.GetText("Log_paragraph").."* Error: " .. _tblErrorMessages[err] .."\r\n");
end
end
end
end
else
-- not connected
Dialog.Message("Not Connected", "You must connect to an FTP server before you can upload a file.", MB_OK, MB_ICONEXCLAMATION);
end
Im sory for my bad ingles