-
May 25th, 2006, 05:37 AM
#1
Thread Starter
Addicted Member
-
May 25th, 2006, 05:40 AM
#2
Thread Starter
Addicted Member
Re: Problems downloading with FTP!
I'm maybe using the command wrong...this is my code:
VB Code:
Set oFTP = New CFtp
oFTP.Connect "ftp.gratisplaneten.com", "xxxx", "xxxx"
oFTP.TransferType = FTP_TRANSFER_TYPE_ASCII 'or FTP_TRANSFER_TYPE_BINARY
oFTP.DownloadFile "brain.txt", "/guitar.gratisplaneten.com/adam/brain.txt"
Dim oFile As CFtpFile
For Each oFile In oFTP.Files
If oFile.IsDirectory Then
List1.AddItem "[" & oFile.FileName & "]"
Else
List1.AddItem oFile.FileName
End If
Next
oFTP.CloseConnection
Shouldn't it work??
-
May 25th, 2006, 05:02 PM
#3
Re: Problems downloading with FTP!
is that file in the root ftp directory, because if it is not, you will need to give the full path to it on the server. Also you have the 2 switched, the first one is remote file loc the second is local folder
probably like this below
VB Code:
oFTP.ChangeDir "/path_to_file_directory/"
'oFTP.DownloadFile "Remote File", "LocalFile"
oFTP.DownloadFile "brain.txt", "/My Documents/adam/brain.txt"
Hope this helps
-
May 26th, 2006, 02:41 AM
#4
Thread Starter
Addicted Member
AARRGHH!! FTP problems!!
I can't get it!!!
Why doesn't this work!?!?
VB Code:
Set oFTP = New CFtp
oFTP.Connect "ftp.guitar.gratisplaneten.com", "xxxxxxxxxx", "xxxxxxxxx"
oFTP.TransferType = FTP_TRANSFER_TYPE_ASCII 'or FTP_TRANSFER_TYPE_BINARY
oFTP.DownloadFile App.Path & "\brain.txt", "/adam/brain.txt"
Dim oFile As CFtpFile
oFTP.ListDir "*", True '<- Second argument (optional): NoCache
For Each oFile In oFTP.Files
If oFile.IsDirectory Then
List1.AddItem "[" & oFile.FileName & "]"
Else
List1.AddItem oFile.FileName
End If
Next
Dim sText As String
Open App.Path & "\brain.txt" For Input As #1
sText = Input(LOF(1), #1)
Close #1
Text1.Text = sText
I've built the download thing after Joacim Anderssons FTP thing here.
But when it comes to the place where it's supposed to open the file and put it into Text1 it says: "File not found"...why!?!?!
Please help me! I'm going crazy on this problem!
//Alex
Last edited by cyber_alex; May 26th, 2006 at 02:49 AM.
-
May 26th, 2006, 03:43 AM
#5
Re: AARRGHH!! FTP problems!!
The file that doesn't exist yet.
Extract from VB's help...
"You must open a file before any I/O operation can be performed on it. Open allocates a buffer for I/O to the file and determines the mode of access to use with the buffer.
If the file specified by pathname doesn't exist, it is created when a file is opened for Append, Binary, Output, or Random modes"
Note the lack of the word "Input".
Create an empty text file with notepad and run it again. (You can also do it with code earlier in the procedure)
Last edited by schoolbusdriver; May 26th, 2006 at 03:46 AM.
Reason: More info
-
May 26th, 2006, 04:00 AM
#6
Thread Starter
Addicted Member
Re: AARRGHH!! FTP problems!!
okey, now it doesn't complain about that the file doesn't exist...but it still doesn't download it.. ...wonder what it can be...
-
May 26th, 2006, 05:36 AM
#7
Fanatic Member
Re: AARRGHH!! FTP problems!!
You need to look at Joacim's thing again.
An event is fired once the file is downloaded. It is in this event that you should open the file and put the contents in the textbox. Your code above tries to open the file before it is finished downloading.
r0ach™
Don't forget to rate the post
-
May 26th, 2006, 05:39 AM
#8
Thread Starter
Addicted Member
Re: AARRGHH!! FTP problems!!
okey, that sounds resonable...I'll try that soon! Tnx!
-
May 26th, 2006, 06:01 AM
#9
Re: AARRGHH!! FTP problems!!
you have the file paths reversed, that downloader uses remote path first and local path second
VB Code:
Public Function DownloadFile(ByVal RemoteFile As String, ByVal LocalFile As String) As Boolean
'you have
oFTP.DownloadFile App.Path & "\brain.txt", "/adam/brain.txt"
'should be
oFTP.DownloadFile "/adam/brain.txt", App.Path & "\brain.txt"
-
May 26th, 2006, 06:03 AM
#10
Thread Starter
Addicted Member
Re: AARRGHH!! FTP problems!!
tnx for your help! I'll reputate at once !
-
May 26th, 2006, 06:04 AM
#11
Thread Starter
Addicted Member
Re: AARRGHH!! FTP problems!!
I'm not allowed to reputate you now since I reputated you for a while ago...well, well.
-
May 26th, 2006, 06:12 AM
#12
Re: AARRGHH!! FTP problems!!
Originally Posted by cyber_alex
I'm not allowed to reputate you now since I reputated you for a while ago...well, well.
So, is this resolved?
(Duplicate threads merged)
-
May 26th, 2006, 06:14 AM
#13
Thread Starter
Addicted Member
Re: AARRGHH!! FTP problems!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|