FTP Help( FtpSetCurrentDirectory() )?

This is a discussion on FTP Help( FtpSetCurrentDirectory() )? within the Windows Programming forums, part of the Platform Specific Boards category; I am working on an FTP program. I was wondering how to use FtpSetCurrentDirectroy(). According to MSDN it goes like ...

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question FTP Help( FtpSetCurrentDirectory() )?

    I am working on an FTP program. I was wondering how to use FtpSetCurrentDirectroy(). According to MSDN it goes like this:


    BOOL WINAPI FtpGetFile(
    HINTERNET hConnect,
    LPCTSTR lpszRemoteFile,
    LPCTSTR lpszNewFile,
    BOOL fFailIfExists,
    DWORD dwFlagsAndAttributes,
    DWORD dwFlags,
    DWORD dwContext
    );


    How do I get the HINTERNET. It is the handle to a valid FTP session. That's basically all I need! Thanks!
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey SyntaxBubble,

    In an ftp connection you should have to varibles of HINTERNET.

    Here is a bit of code to see what hInstance is:

    Code:
    BOOL      	bSuccess;
    HINTERNET      hIntSession, hFtpSession;
    
    // Open an internet session
    
    hIntSession = ::InternetOpen ("FTP", INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_ASYNC);
    
    // form a connection to www.aspect2k.com
    
           hFtpSession = InternetConnect (hIntSession, "www.aspect2k.com", 
          	INTERNET_DEFAULT_FTP_PORT, "anonymous", "tntcoder@hotmail.com", 
          	INTERNET_SERVICE_FTP, 0, 0);
    
          bSuccess = FtpSetCurrentDirectory( hFtpSession, "");      
    
    
    
    
          InternetCloseHandle (hFtpSession);
          InternetCloseHandle (hIntSession);
    That sets the current directory to the default root.

    TNT
    Last edited by (TNT); 01-18-2002 at 03:29 PM.
    TNT
    You Can Stop Me, But You Cant Stop Us All

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question After that then...

    Now I got that working. How would I retrieve all files from the dir and put the file names in the listbox?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  4. #4
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey,

    Dunno why i called you garfield before lol...

    MSDN has a thing on FindFirstFile(), (internet platform sdk). You can use that function to get all the files.

    I am not 100% sure about this i have never tried it,

    prot:

    HRESULT FindFirstFile(
    [in, string] LPCWSTR wsSearchFile
    [out] LPWIN32_FIND_DATAW pFindFileData
    [out] LPHANDLE pSearchHandle
    );


    so mabey you could do somthing like FindFirestFile("*.*" ....)

    Sorry i cant be of more help

    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  5. #5
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125
    if you want to obtain the files on remote servers you have to use FtpFindFirstFile() and FtpFindNextFile(). this should find all the files in the directory you set before.

    hFindFile = FtpFindFirstFile(hService,"*.**",&dwFlags,INTERNET _FLAG_RELOAD,0);
    if(hFindFile) {
    //setup error handing for no files.
    }
    while(InternetFindNextFile(hFIndFile,&dwFlags)) {
    if( (dwFlags.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) {
    //send directory name to listbox
    }
    else
    send files name to listbox
    }
    else {
    //setup error handling for no files on server.
    }

    hope this helps.
    arrh, i got nothing good to say.
    http://www.praxis1.vic.edu.au/home/dcola/

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    Don't forget to close the FindFile() ect with FindClose() ect.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to program in unix
    By Cpro in forum Linux Programming
    Replies: 21
    Last Post: 02-12-2008, 09:54 AM
  2. FTP problems...
    By gcn_zelda in forum Tech Board
    Replies: 9
    Last Post: 08-03-2004, 11:05 PM
  3. FTP and Ident Server :: Winsock
    By kuphryn in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-13-2004, 07:16 PM
  4. [C++] FTP client problem (winsock)
    By Niekie in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-19-2003, 09:23 AM
  5. FTP Server :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 10-03-2002, 07:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21