Ftp Object : Store Method |
Visual Basic |
---|
Public Sub Store( _ ByVal RemoteFileName As String, _ Optional ByVal Data As Variant, _ Optional ByVal Marker As Long = 0, _ Optional ByVal MarkerHigh As Long = 0 _ ) |
Sequences and sends (if needed) the following commands (refer to the CommandConstants topic for more information on these commands):
Depending on the value of Marker and the StoreType property, ftpStoreUnique or ftpAppend may be sent instead of ftpStore.
If Marker is used, the ftpAppend command is used to send the data, so Marker must accurately reflects the size of the file on the server (since the data will be appended).
The Progress and Progress64 events fire as each file segment is sent or reply is received. If Timeout is greater than 0, Store blocks until the file is sent to the server or a ptTimeout error occurs. If Timeout is 0, Store immediately returns. In this case, if the Result parameter is used to capture the data, it must not go out of scope while the command completes (it must have file or global scope).
The Store method fires a ptFile error if the local file exists but could not be opened.
If Type is ftpZip the file or files specified in Data will be automatically compressed and transferred to the remote directory and file name identified in the URL. The URL must contain the name of the remote file. The file placed on the remote server will have an extension of .zip. The Data parameter is not optional if the ftpZip type is used. For more advanced zip functionality, please look at PowerTCP Zip Compression for ActiveX at www.dart.com.
MarkerHigh should be set to the value of the restart position divided by 2^31 (2147483648). Marker should be set to the remainder of this operation.
A ptInvalidParam2 error will occur if the size of Data is larger than 2^31 and is NOT a file.
If you wish to use a DartStream object as Result, you must first add a reference to DartSock.dll.
This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):
Private Sub Command1_Click() On Error Goto OnError ' use intrinsic error handling Ftp1.Timeout = 1000 ' Store a binary file on the server Ftp1.Type = ftpImage Ftp1.Store "TheFile.exe" Exit Sub OnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description End Sub
Private Sub Command1_Click() On Error Goto onError ' Login to the server Ftp1.Login "MyFtpServer", "MyUsername", "MyPass" ' Specify the file type as ftpZip, this will cause it to be compressed, ' then stored Ftp1.Type = ftpZip ' Store the file, since Type is ftpZip, it will be zipped first Ftp1.Store "ftpzip.zip", "c:\temp\test.htm" ' Logout Ftp1.Logout Exit Sub onError: Debug.Print Err.Description End Sub