Results 1 to 11 of 11

Thread: FTP text file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    122

    FTP text file

    Hi all ,

    Iam looking for a sample code where i can open a ftp connection ,send text file and save it.. can anybody help me with this...

    thanks

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: FTP text file

    ....
    Attached Files Attached Files
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: FTP text file

    You could simply shell out to the FTP.exe program or you can use the FtpPutFile API function.
    VB Code:
    1. Private Declare Function InternetOpen Lib "wininet.dll" _
    2.  Alias "InternetOpenA" ( _
    3.  ByVal sAgent As String, _
    4.  ByVal nAccessType As Long, _
    5.  ByVal sProxyName As String, _
    6.  ByVal sProxyBypass As String, _
    7.  ByVal nFlags As Long) As Long
    8.  
    9. Private Declare Function InternetConnect _
    10.  Lib "wininet.dll" Alias "InternetConnectA" ( _
    11.  ByVal hInternetSession As Long, _
    12.  ByVal sServerName As String, _
    13.  ByVal nServerPort As Integer, _
    14.  ByVal sUserName As String, _
    15.  ByVal sPassword As String, _
    16.  ByVal nService As Long, _
    17.  ByVal dwFlags As Long, _
    18.  ByVal dwContext As Long) As Long
    19.  
    20. Private Declare Function InternetCloseHandle _
    21.  Lib "wininet.dll" ( _
    22.  ByVal hInet As Long) As Integer
    23.  
    24. Private Declare Function FtpPutFile _
    25.  Lib "wininet.dll" Alias "FtpPutFileA" ( _
    26.  ByVal hFtpSession As Long, _
    27.  ByVal lpszLocalFile As String, _
    28.  ByVal lpszRemoteFile As String, _
    29.  ByVal dwFlags As Long, _
    30.  ByVal dwContext As Long) As Boolean
    The steps are to call InternetOpen and with the returned handle call the InternetConnect function. The handle returned by that function is in turn used with the FtpPutFile function. When you're done you need to close the two handles using InternetCloseHandle.

    I've attached an article I wrote a few years back that explains these functions in more detail.
    Attached Files Attached Files

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: FTP text file

    Sorry didn't notice that Dave already posted my article

  5. #5
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: FTP text file

    Quote Originally Posted by Joacim Andersson
    Sorry didn't notice that Dave already posted my article
    Very well-written I might add.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  6. #6
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: FTP text file

    Quote Originally Posted by Joacim Andersson
    Sorry didn't notice that Dave already posted my article
    I wasn't able to find the CFTP Class you made. Where is it, I'd like to use it.

    Thanks!

    Dave
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: FTP text file

    I don't have the origional CFtp class I made for that article anymore, but I have an extended version of it . But since you asked so nicely or maybe because of the chance to get this post rated I've post not only that class but a whole project. This project is my File Courier application that comes with my Source Edit program. File Courier is a complete FTP client. You may not redistibute this code or the whole application but you may use the classes in it in your own application. Just look at the project as an implementation of how to use the different classes.

    Cheers,

    J
    Attached Files Attached Files

  8. #8
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: FTP text file

    Quote Originally Posted by Joacim Andersson
    I don't have the origional CFtp class I made for that article anymore, but I have an extended version of it . But since you asked so nicely or maybe because of the chance to get this post rated I've post not only that class but a whole project. This project is my File Courier application that comes with my Source Edit program. File Courier is a complete FTP client. You may not redistibute this code or the whole application but you may use the classes in it in your own application. Just look at the project as an implementation of how to use the different classes.

    Cheers,

    J
    Cross my heart, hope to die, stick a needle in my eye!

    hehe I am only intertested in your classes... Thanks alot! I may modify the Classes slightly to suit my personal goals. Hope thats OK, I can post any new changes should you be interested in them.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  9. #9
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: FTP text file

    Not to worry, the project cannot be loaded or executed or compiled anyway. It barfs on a few missing DLLs:

    Line 21: Class CCRPFolderTV6.FolderTreeview of control ftree was not a loaded control class.

    Missing: TimerEx.dll
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: FTP text file

    Quote Originally Posted by Dave Sell
    Not to worry, the project cannot be loaded or executed or compiled anyway. It barfs on a few missing DLLs:

    Line 21: Class CCRPFolderTV6.FolderTreeview of control ftree was not a loaded control class.

    Missing: TimerEx.dll
    Oh yeah, sorry about that. The FolderTreeView can be downloaded from http://ccrp.mvps.org and I'll upload the source for the Timer.
    Attached Files Attached Files

  11. #11
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: FTP text file

    Quote Originally Posted by Dave Sell
    I may modify the Classes slightly to suit my personal goals. Hope thats OK, I can post any new changes should you be interested in them.
    Do whatever you want with the classes, you don't have to post the changes if you don't want to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width