Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. FTP Connection

FTP Connection

Scheduled Pinned Locked Moved C#
sysadminquestion
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MumbleB
    wrote on last edited by
    #1

    Hi guys. I am looking for a simple FTP connection. I have an FTP Server running on my local machine. How do I connect to this FTP server using code? All the samples I find refer to a WEB FTP connection. Can somebody direct me to a simple ftp connection that connects to either a local FTP server or connection to an FTP server on a network? Thanks guys.

    Excellence is doing ordinary things extraordinarily well.

    L 1 Reply Last reply
    0
    • M MumbleB

      Hi guys. I am looking for a simple FTP connection. I have an FTP Server running on my local machine. How do I connect to this FTP server using code? All the samples I find refer to a WEB FTP connection. Can somebody direct me to a simple ftp connection that connects to either a local FTP server or connection to an FTP server on a network? Thanks guys.

      Excellence is doing ordinary things extraordinarily well.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      I expect FtpWebRequest to work similar to HttpWebRequest, so use the IP address and go ahead. Whether your server is local or on the Internet seems irrelevant to me. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, and update CP Vanity to V2.0 if you haven't already.

      S 1 Reply Last reply
      0
      • L Luc Pattyn

        I expect FtpWebRequest to work similar to HttpWebRequest, so use the IP address and go ahead. Whether your server is local or on the Internet seems irrelevant to me. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, and update CP Vanity to V2.0 if you haven't already.

        S Offline
        S Offline
        Sunil G 3
        wrote on last edited by
        #3

        Hi, You can use below API's...

        Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
        Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
        Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
        Private Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
        Private Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String, lpdwCurrentDirectory As Long) As Long
        Private Declare Function FtpCreateDirectory Lib "wininet.dll" Alias "FtpCreateDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
        Private Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias "FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
        Private Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As Boolean
        Private Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String, ByVal lpszNew As String) As Boolean
        Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean
        Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

        Regards, SunilG.

        L 1 Reply Last reply
        0
        • S Sunil G 3

          Hi, You can use below API's...

          Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
          Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
          Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
          Private Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
          Private Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String, lpdwCurrentDirectory As Long) As Long
          Private Declare Function FtpCreateDirectory Lib "wininet.dll" Alias "FtpCreateDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
          Private Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias "FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
          Private Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As Boolean
          Private Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String, ByVal lpszNew As String) As Boolean
          Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean
          Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

          Regards, SunilG.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Thanks for that, however: 1. I'm not the one asking for an FTP solution; you replied to the wrong message. 2. This is the C# forum, no need for VB code. 3. And why would we use P/Invoke when .NET itself has what is required. :(

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          P S 2 Replies Last reply
          0
          • L Luc Pattyn

            Thanks for that, however: 1. I'm not the one asking for an FTP solution; you replied to the wrong message. 2. This is the C# forum, no need for VB code. 3. And why would we use P/Invoke when .NET itself has what is required. :(

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            Apart from that, what have the Romans ever done for us?

            I'm not a stalker, I just know things. Oh by the way, you're out of milk.

            Forgive your enemies - it messes with their heads

            My blog | My articles | MoXAML PowerToys | Onyx

            L 1 Reply Last reply
            0
            • P Pete OHanlon

              Apart from that, what have the Romans ever done for us?

              I'm not a stalker, I just know things. Oh by the way, you're out of milk.

              Forgive your enemies - it messes with their heads

              My blog | My articles | MoXAML PowerToys | Onyx

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Pete O'Hanlon wrote:

              what have the Romans ever done for us?

              Lots of good things came from the Romans. They gave us nice roads, connecting major cities, sometimes in remarkably straight lines; admittedly, they haven't been upgraded soon enough (the roads I mean), so now we sometimes have a bit of a jam. And then they gave you the Hadrian Wall, to protect you against neighboring savages. How can you forget all that? :doh:

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

              P 1 Reply Last reply
              0
              • L Luc Pattyn

                Pete O'Hanlon wrote:

                what have the Romans ever done for us?

                Lots of good things came from the Romans. They gave us nice roads, connecting major cities, sometimes in remarkably straight lines; admittedly, they haven't been upgraded soon enough (the roads I mean), so now we sometimes have a bit of a jam. And then they gave you the Hadrian Wall, to protect you against neighboring savages. How can you forget all that? :doh:

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                Not a Monty Python fan then I take it. Clickety[^]

                I'm not a stalker, I just know things. Oh by the way, you're out of milk.

                Forgive your enemies - it messes with their heads

                My blog | My articles | MoXAML PowerToys | Onyx

                L 2 Replies Last reply
                0
                • P Pete OHanlon

                  Not a Monty Python fan then I take it. Clickety[^]

                  I'm not a stalker, I just know things. Oh by the way, you're out of milk.

                  Forgive your enemies - it messes with their heads

                  My blog | My articles | MoXAML PowerToys | Onyx

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  Under other circumstances, yes, I am, very much so. I do appreciate the classics. Questions in programming forums are always taken seriously though. Well, maybe not really always... :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                  1 Reply Last reply
                  0
                  • P Pete OHanlon

                    Not a Monty Python fan then I take it. Clickety[^]

                    I'm not a stalker, I just know things. Oh by the way, you're out of milk.

                    Forgive your enemies - it messes with their heads

                    My blog | My articles | MoXAML PowerToys | Onyx

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    Forgot to mention, I also appreciate Cleese's more serious stuff: his business training movies, seminars, etc. Enjoyed a couple of interviews he gave. Quite a guy. :)

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                    Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                    1 Reply Last reply
                    0
                    • L Luc Pattyn

                      Thanks for that, however: 1. I'm not the one asking for an FTP solution; you replied to the wrong message. 2. This is the C# forum, no need for VB code. 3. And why would we use P/Invoke when .NET itself has what is required. :(

                      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                      S Offline
                      S Offline
                      Sunil G 3
                      wrote on last edited by
                      #10

                      My dear friend, I havent told you to copy and paste all the APIs in C#. You can you these APIs in C# only the syntax is different. Regards,

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups