I'm currently rebuilding a spreadsheet that I have been working on and I'm needing to add the ability to open a user chosen file from an FTP server. I know that the open file dialog is available for opening local files. Can it be made to open a file on an FTP server and how would one go about that.
The server does have a password. So this would be another obstacle to over come. Any suggestions on where to find info on that. I accidentally came across the info on reading FTP hosted files into a spread sheet using the username:pasword@ftp formula which works great for a single file. We need access to archived files which are created using the date and time as the file name. I've played with the Open File Dialog macro from Andrew Pitonyak's Useful Macro Info book. I've not been able to get it to open access to an FTP site.
Delete all Directories ( Folders ) and Subdirectories ( Subfolders ) Recursively using C# and VB.Net. Download Free Files API. Download Free Files API. In this article I will explain how to delete a folder or directory in C# or VB.Net. Directory or Folder is an entity that can contain multiple folders or files in it. How to download file from ftp server using vb.net 2008 FTP File Download Multiple Thread FtpWebRequest saving downloaded file with encoded characters in the file name.
I figured it might be similar to a mapped drive. I know it uses different protocols but I figured windows was that far along. So I'll be able to use it to access local files no problem. I've also got an idea how to pull a single file from the FTP server but without a way to browse the archived items I'm kind of screwed on those files.
Some means to read the files from the directory on the FTP file should work as well. This one is killing me.
What about the Path Setting Services from section 5.36 of Andy's book. Storage has to do with FTP, Mail and other information. Or am I just grasping at straws.
![All All](http://images.directoryofshareware.com/full/ftp_client_engine_for_delphi_development_delphi-142559.gif)
Not really an issue other than I don't know how to do it. Here is the Code I snagged from Andy's book Code: 'Opens a Open File Dialog to allow the end user to select a file to import into the program. 'This code is from Andrew Pitonyak's free Useful Macros book Function fOpenFile as String Dim oFileDialog as Object Dim iAccept as Integer Dim sPath as String Dim InitPath as String Dim RefControlName as String Dim oUcb as object Dim filterNames(5) as String filterNames(0) = '.csv' filterNames(1) = '.txt' filterNames(2) = '.odt' filterNames(3) = '.ods' filterNames(4) = '.xlt' filterNames(5) = '.xls' 'Dim ListAny(0) GlobalScope.BasicLibraries.LoadLibrary('Tools') 'Note: The following services must be called in the following order, ' otherwise the FileDialog Service is not removed. OFileDialog = CreateUnoService('com.sun.star.ui.dialogs.FilePicker') ' Defaults to Open, you can also use Save 'oFileDialog.Initialize( ' Array(com.sun.star.ui.dialogs.TemplateDescription.FILESAVESIMPLE)) oUcb = createUnoService('com.sun.star.ucb.SimpleFileAccess') 'ListAny(0) = ' com.sun.star.ui.dialogs.TemplateDescription.FILEOPENSIMPLE 'oFileDialog.initialize(ListAny) AddFiltersToDialog(FilterNames, oFileDialog) 'Set your initial path here! 'InitPath = ConvertToUrl(oRefModel.Text) If InitPath = ' Then InitPath = GetPathSettings('Work') End If If oUcb.Exists(InitPath) Then oFileDialog.SetDisplayDirectory(InitPath) End If iAccept = oFileDialog.Execute If iAccept = 1 Then sPath = oFileDialog.Files(0) fOpenFile = sPath 'If oUcb.Exists(sPath) Then ' oRefModel.Text = ConvertFromUrl(sPath) 'End If End If oFileDialog.Dispose End Function As you can see he has sections commented out. I have no idea what to change to make this macro work for me. Also I have to problem of the users that will be getting this file might not have the OOo dialogs enabled.
Mine copy did not by default therefore I want to be able to do it with the regular dialog or have in the macro a way to force the other macro. Any guidance is appreciated. Hi, try Code: sub main msgbox fOpenFile end sub Function fOpenFile as String oFileDialog = CreateUnoService('com.sun.star.ui.dialogs.OfficeFilePicker') InitPath = ConvertToUrl('ftp://user:[email protected]') oFileDialog.setDisplayDirectory(InitPath) iAccept = oFileDialog.Execute If iAccept = 1 Then sPath = oFileDialog.Files(0) fOpenFile = sPath End If oFileDialog.Dispose End Function Note that a different service is instantiated (OfficeFilepicker). This ensures that independent of the config, OOs file picker is used Good luck, ms777 Volunteer Posts: 131 Joined: Mon Oct 08, 2007 1:33 am. Hi ms777, Your code does not work for me if the ftp needs a user and password. I tested it with the ftp address and password used to access my personal web page. After a few seconds I get an error message 'impossible to establish Internet connection to xxxxx.yyy.fr'.
If I copy the same data to my Opera browser's address field, I successfully display the root folder. So I think OOo is not fully compliant with the ftp protocol. For an anonymous ftp, no problem. Bernard Volunteer Posts: 1160 Joined: Mon Oct 08, 2007 1:26 am Location: France, Paris area.
Ms777 wrote:this is strange. I tested the code with my personal, password protected ftp site, and it worked Would you be hosting this FTP server on your computer or have it on the local network?
The FTP server I'm trying to access works fine from a cell formula but I cannot get this dialog box to do anything with it. Also using the OOo Dialog box keeps the standard windows dialog from working when I try to use that one in the other macro. I prefer using it as it is easier to navigate to the Desktop or My Docs for the end user. So I messed up. The code works just fine. I misspelled the path. Therefore it doesn't work.
Thank you for the code MS777 So how would I go about fixing my other code to only use the Windows Open File dialog? I'd rather use it for the local file importing as the FTP doesn't need any real navigation and most peeps are used to the Windows version. Could I simply reuse your code without the File Dialog service being activated or is it one of those once it is set you cannot use the other dialog? I have one more question that, for the sake of simplifying the forum flow, I will ask within this same topic.
Using the above code (Which I had no problems with adapting to use for local files and such) how can I implement file filters and multi select mode?