| Dart Home | PowerTCP FTP for ActiveX | Custom Development | Reply | PowerTCP FTP for ActiveX Topics | Forums |
| Author | Forum: PowerTCP FTP for ActiveX Topic: Retrieve Method - Parameter 2 of the method used is invalid or not appropriate |
| celeronmanuk From: High Wycombe, United Kingdom Posts: 4 Member Since: 11/16/05 |
posted November 16, 2005 9:42 AM I'm Trying to upgrade our ASP application from 1.8.0.9 to 1.8.4.0. I now get the following error when trying to use the Retrieve method: Dart.Ftp.1 error '800a2ee2' Parameter 2 of the method used is invalid or not appropriate. Looking at the documentation, I can't see anything wrong with my code! The code producing the error is: Set objDirFTP = Server.CreateObject("Dart.Ftp.1") objDirFTP.Passive = FTP_Passive objDirFTP.Login FTP_Host, FTP_Username, FTP_Password objDirFTP.Retrieve Directory & "/" & File, strFile objDirFTP.logout set objDirFTP = nothing This was working before the upgrade! |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 16, 2005 10:00 AM Where is strFile declared and initialized? My guess is that you are passing in an empty string by value. In previous versions, when you did this, we would not throw an error, however the transfer would still occur without a file being written. |
| celeronmanuk From: High Wycombe, United Kingdom Posts: 4 Member Since: 11/16/05 |
posted November 16, 2005 10:11 AM Thanks for the quick reply. strFile is an empty string Dim strFile strFile = "" I was using the Retrieve method to populate the string with the files contents as described in the documentation. I was then manipulating the content of this string before saving to the local file system. Result Optional String specifying the (local) destination file name, or an undimensioned String or Byte array that is dynamically expanded and filled with file data. If not specified or NULL, the FileName parameter (without path) is used as the local file name and put into the current default directory. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 16, 2005 11:23 AM In order to fix errors that occurred in some other environments, we had to start throwing an error when the Variant was passed in as type VT_BSTR with a size of 0. This is what happens when you pass "" to every other environment. When you pass in an empty string variable, other environments pass it to us as type VT_BSTR | VT_BYREF (by ref string) and we know that it is safe to retain this variable to fill in later. Do you know how to get VBScript to pass strFile by reference? If so, that would be an immediate solution. |
| celeronmanuk From: High Wycombe, United Kingdom Posts: 4 Member Since: 11/16/05 |
posted November 16, 2005 12:11 PM I'm not aware of any way to pass the variant to the component as VT_BSTR | VT_BYREF in vbscript. Do you know if this is possible? I don't think it's supported? How does the component know if i'm passing it a (local) destination file name or a string to populate with data? |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 16, 2005 1:31 PM The way it is supposed to work is as follows: 1) If Result.Vt = VT_BSTR and it's size is 0, then we assume you passed in "" and throw an error because we will not be able to "grow" the BSTR for filling in with data. 2) If Result.VT = VT_BSTR or VT_BSTR | VT_BYREF and size is greater than 0, then you passed in a dimensioned string which we use as the filename. 3) If Result.Vt = VT_BSTR | VT_BYREF and it's size is 0 then you passed in a variable that you declared and set to "". This string will be filled in by us. 4) If Result.Vt = VT_DISPATCH then it is a DartStream object which we save and write to as the data comes in I'm still trying to figure out what is going on, but in the meantime, here is some workaround code for you. Instead of passing the string, pass a DartStream, then read that into your string, like so: Dim dsFile set dsFile = Server.CreateObject("Dart.DartStream.1") ftp1.Retrieve "test.txt", dsFile Dim strFile dsFile.Position = 0 strFile = dsfile.ReadString |
| celeronmanuk From: High Wycombe, United Kingdom Posts: 4 Member Since: 11/16/05 |
posted November 17, 2005 4:50 AM Thanks Tony That all makes sense now. Passing a DartStream works perfectly. |
| Reply | PowerTCP FTP for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|