 |
| Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 29th, 2003, 11:36 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I took the code fig000 posted and put it right into an application with no problems. I didn't have to change much if anything at all if I remember correctly.
Good luck all
Thanks,
Risu
|
|

October 30th, 2003, 11:15 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In regards to fig000's post regarding the simple FTP solution. I too am trying to implement such a solution in VB.NET but the FTPGetFile is not working for me either. Always returns false and doesn't get the file. We've had problems running these same steps through a .cmd script when running on an XP box (get a 550 disconnect error) but it works fine on an NT box, which I why I'm attempting to do this in VB.NET. I think there maybe something wrong with the FTP client on XP. Just wondering if those of you who have had success with this code are running on NT boxes? Has anyone got it working on an XP box? Thanks.
|
|

October 30th, 2003, 12:26 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
grover4444,
Very good point, when I ran it it was on a 2k box not an XP box. Unfortunately I do not have an XP box to try it out on.
Hope this little bit helps.
Thanks, Risu
|
|

November 2nd, 2003, 01:37 PM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Too all Free-FTP-seekers!
this link might just be what you are looking for.
http://www.aspsimply.com/VBNet/DotNetFTP.aspx
Rastafary!
|
|

November 3rd, 2003, 07:51 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Buying a component is an Expensive Option.
The internet trasfer control does not work for FTP and the code using the WinAPI calls only works on some servers. I wish I knew why.
|
|

November 3rd, 2003, 11:09 PM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I got it to work fine with XP. I used pretty much the code that was provided above by fig000.
Private Function GetFile(ByVal machine As String) As String
' Open an FTP connection to the machine and get myfile.txt
' Connect (for now) to user1 only
Dim INet, INetConn As Integer
Dim RC As Boolean
INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)
INetConn = InternetConnect(INet, machine, 0, "user1", "password", 1, 0, 0)
RC = FtpGetFile(INetConn, "~/myfile.txt", "c:\\temp\\myfile." & machine & ".txt", True, 1, 1, 0)
If RC Then MessageBox.Show("Transfer succesfull!")
InternetCloseHandle(INetConn)
InternetCloseHandle(INet)
End Function
Quote:
quote:Originally posted by grover4444
In regards to fig000's post regarding the simple FTP solution. I too am trying to implement such a solution in VB.NET but the FTPGetFile is not working for me either. Always returns false and doesn't get the file. We've had problems running these same steps through a .cmd script when running on an XP box (get a 550 disconnect error) but it works fine on an NT box, which I why I'm attempting to do this in VB.NET. I think there maybe something wrong with the FTP client on XP. Just wondering if those of you who have had success with this code are running on NT boxes? Has anyone got it working on an XP box? Thanks.
|
|
|

November 18th, 2003, 11:52 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Along the lines of this, I was wondering if there is a way to either delete the file on the FTP server after you get it or to rename it. If anyone has links to any documentation of wininet that may list it's functions would also help to see whats available.
Thanks,
Risu
|
|

January 9th, 2004, 05:43 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
FYI...
I spent ALL day today trying to find a way to simply FTP a file to my ftp site using VB.NET.
I heard about fig000's solution on another site, but I couldn't find the actual code... then I finally stumbled on this thread.
At first, I had the same problem as everyone else... the GetFile would always return False...
...then I tried the dll solution that DesertPalm linked to. Actually, I had already tried that solution earlier in the day, and I still had a project open that referenced that dll, so I figured that I'd give it another shot. Each time, the Upload_Download Sub would always return "False", just like the GetFile function in the API solution... Well, fortunately, the DLL function includes the ability to create a connection log file... so after a number of trial-and-error attempts and log checks, I found that my problem was simply that I was not typing the "RemoteFile" path correctly.
Once I figured out how to write the RemoteFile path, both the DLL solution and the API solution worked just fine.
The problem is... the defualt folder that you are linked to when you log in to an FTP server is different from server to server. And in the case of my server, it already adds the trailing "/" to the defualt folder. So all I had to do was change my RemoteFile from "/MyFiles/myfile.txt" to "MyFiles/myfile.txt" and it worked.
So try messing around with the path you're using in the RemoteFile string, and you may get it to work.
WATYF
|
|

February 12th, 2004, 03:43 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Does anyone know whether a success return value from a call to FTPPutFile means that the file was created successfully with the exact # of bytes in it ?
|
|

March 17th, 2004, 05:05 AM
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've tried to run the putfile in XP box, and it working fine.
Hope it help ppl. : )
' --------------------
' Transfer via standard FTP
ServerName = strLocation.ToUpper
FTPLogin = txtUserID.Text
FTPPassword = txtPassword.Text
' Instantiate a new FTP object
Dim INet, INetConn As Integer
Dim RC As Boolean
' FTP_TRANSFER_TYPE_ASCII
' FTP_TRANSFER_TYPE_BINARY
INet = InternetOpen("CTM_SMS_FTP_Control", 1, vbNullString, vbNullString, 0)
INetConn = InternetConnect(INet, ServerName, 0, FTPLogin, FTPPassword, 1, 0, 0)
RC = FtpPutFile(INetConn, strFileName, "\a\upload.txt", 0, 0)
If RC Then
MsgBox("Transfer succesfull!")
End If
InternetCloseHandle(INetConn)
InternetCloseHandle(INet)
'------------------
Keung
|
|
 |