Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #31 (permalink)  
Old May 23rd, 2005, 05:57 PM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

fig000 i really want to try ur code but for reading txt files from unix environment.
will appreciate your help
thanks pantea

Reply With Quote
  #32 (permalink)  
Old August 29th, 2007, 01:22 PM
Registered User
 
Join Date: Aug 2007
Location: TALLAHASEE, FL, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I am also having the same problem. I need to place a file at "ftp.com.county.ca.us". I tried with the script provide above I am unable to even connect to the ftp. Is there any other way to do this.
Thanks.

Reply With Quote
  #33 (permalink)  
Old May 7th, 2008, 02:29 PM
Registered User
 
Join Date: May 2008
Location: Akron, OH, .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the FtpGetFile function working on an XP System with no problems. However, I wish to use this code for a client that will be running Windows 2000 Professional. I did a little looking around and found that this OS is under the requirements for operating systems (http://msdn.microsoft.com/en-us/library/aa384157(VS.85).aspx).

I am running Windows 2000 on a virtual server. I am looking for a specific file name. The function brings it down correctly the first time. I delete it from the remote location. I drop another file of the same name, but different size and content. When the function is called a second time, it downloads the same file as the first attempt, even though that file was deleted and no longer a possibility of being downloaded. This happens over and over until I restart the application and then whatever file I get with FtpGetFile the first time mimics the same odd behavior as I mentioned above. Does anyone know how to switch off any cacheing (if that is the case) to get this to work?

Keep in mind I have run this same software application on another Win XP system and a Win 2003 (virtual server) system using the same FTP source with no problems. This odd behavior only occurs on the Windows 2000 OS. I am not able to use the actual server at the client, which is why I am using a virtual server image for testing.

My (relevant) code is below:

    Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet As Integer) As Integer
    Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer) As Integer
    Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Integer, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer, ByVal lContext As Integer) As Integer
    Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Integer, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean
    Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean
    Public Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hFtpSession As Integer, ByVal lpszFileName As String) As Boolean

    Dim FTPServiceAlias As String = configurationAppSettings.GetValue("FTPServiceAlias ", GetType(System.String)).ToString
    Dim FTPServerName As String = configurationAppSettings.GetValue("FTPServerName", GetType(System.String)).ToString
    Dim FTPPortNumber As Integer = CInt(configurationAppSettings.GetValue("FTPPortNum ber", GetType(System.String)))
    Dim FTPAccessType As Integer = CInt(configurationAppSettings.GetValue("FTPAccessT ype", GetType(System.String)))
    Dim FTPUserName As String = configurationAppSettings.GetValue("FTPUserName", GetType(System.String)).ToString
    Dim FTPUserPassword As String = configurationAppSettings.GetValue("FTPUserPassword ", GetType(System.String)).ToString
    Dim FTPFolder As String = configurationAppSettings.GetValue("FTPFolder", GetType(System.String)).ToString

 Private Sub GetFileByFTP()
        Try
            Dim INet, INetConn As Integer
            Dim RC As Boolean
            INet = InternetOpen(FTPServiceAlias, FTPAccessType, vbNullString, vbNullString, 0)
            If Err.LastDllError <> 0 Then
                LocalWriteToErrorFile(" FTP InternetOpen Error: " & Err.LastDllError.ToString & ". See http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx for details.")
            End If

            INetConn = InternetConnect(INet, FTPServerName, FTPPortNumber, FTPUserName, FTPUserPassword, 1, 0, 0)

            If Err.LastDllError <> 0 Then
                LocalWriteToErrorFile(" FTP InternetConnect Error: " & Err.LastDllError.ToString & ". See http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx for details.")
            End If

            RC = FtpGetFile(INetConn, ScheduleFile, InputFilePath & "\" & ScheduleFile, True, 1, 0, 0)

            If RC = False And Err.LastDllError <> 80 Then
                LocalWriteToErrorFile(" FTP Get Error: " & Err.LastDllError.ToString & ". See http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx for details.")
            End If

            If CInt(Err.LastDllError) = 0 Then
                Dim timeOut As DateTime = Now.AddMilliseconds(8000)
                RC = FtpDeleteFile(INetConn, ScheduleFile)
                If RC = False And Err.LastDllError <> 0 Then
                    LocalWriteToErrorFile(" FTP Delete Error: " & Err.LastDllError.ToString & ". See http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx for details.")
                End If
            End If

            InternetCloseHandle(INetConn)
            InternetCloseHandle(INet)

        Catch ex As Exception
            LocalWriteToErrorFile(ex.ToString())
        End Try
    End Sub



Reply With Quote
  #34 (permalink)  
Old June 11th, 2011, 03:56 PM
Registered User
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is a good free library that I use to upload and download files using within my VB.NET programs. The library I use is called edtFTP.net and makes it possible to download files using FTP in as little as 7 lines of code. See the snippet below for an example of how easy uploading files are:

Code:
  'connect to ftp server
  Dim ftp As New FTPConnection
  ftp.ServerAddress = "ftp.example.com"
  ftp.UserName = "example_user"
  ftp.Password = "example_pass"
  ftp.Connect()
 
  'upload a file
  ftp.UploadFile("c:\test.txt", "test.txt")
 
  'close the connection
  ftp.Close()
Here is a link to a more detailed example http://zeusarticles.com/how-upload-a...vbnet-easy-way
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Uploading Text File to FTP server in vb.net KiruShan .NET Framework 2.0 4 July 29th, 2014 02:02 AM
loop through tables inside .mdb file using VB.NET remya1000 General .NET 3 September 24th, 2007 12:45 PM
Start a program inside another program Silje Classic ASP Professional 1 November 16th, 2004 01:08 AM
Running FTP within VB .NET Application ocarroll General .NET 7 September 28th, 2004 04:25 PM



All times are GMT -4. The time now is 07:47 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.