CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: About FTP~!~

  1. #1
    Join Date
    Oct 2003
    Posts
    16

    About FTP~!~

    hi, all

    I am doing a project which would download files to a fixed place from a FTP server. And every file would need a new thread. How should I do? I'd never do something about this.

    Nimking

  2. #2
    Join Date
    Nov 2002
    Location
    Lahore, Pakistan
    Posts
    52
    You can use WinInet

    For each file you have to establish a new session with the FTP Server

    All u have to do is to make a class which should take username, password, and file path (to be downloaded or uploaded to and from server) in it's constructor and that class should make a thread for that file and start all the remaining process as memtioned in WinInet classes

  3. #3
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    You can use MS WinInet API (search http://msdn.microsoft.com/library for more info).

    Here's a short desciption on how to do it with WinINet API:
    1. Open internet session with InternetOpen()
    2. Connect to FTP server with InternetConnect()
    3. Download a file with FtpGetFile()
    4. Close both handles (1, 2) with InternetCloseHandle()

    For threading, lookup these functions in the online help:
    1. CreateThread
    2. _beginthread
    3. _beginthreadex

    Hope it helps.

  4. #4
    Join Date
    Oct 2000
    Location
    India
    Posts
    4,620

    Link

    Hi,

    You might want to take a look at http://www.geocities.com/contactgirish/ftp.html

    for code related to uploading and downloading files from a
    FTP server. Its not multithreaded, but that'd be easy to
    implement. Take a look in the MSDN for creating and handling
    threads.

    Hope this helps.
    All luck and have a great day.

    Regards,
    V.Girish

    Visit www.geocities.com/contactgirish for Source code, Tutorials, FAQs and Downloads.

  5. #5
    Join Date
    Oct 2003
    Posts
    16
    If I use two threads download two files at the same time, does it make a wrong? Does I need to split the file?

  6. #6
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    Originally posted by Nimking
    If I use two threads download two files at the same time, does it make a wrong? Does I need to split the file?
    It should work to download two files from separate threads. Note however that the files won't be downloaded faster using two or more threads!!!

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)