cURL / Mailing Lists / curl-library / Single Mail


How to change directory path in FTP server

From: Mohd Idzuan <>
Date: Wed, 12 Apr 2006 14:39:24 +0800


I have successfully connected to FTP server using
the libcurl.NET library in C#. My problem is, how to
change directory in the FTP server, before i can start
uploading files. I managed to returned the root directory
of the FTP server using

easy.SetOpt(CURLoption.CURLOPT_FTPLISTONLY, true);

, but i wonder how to change to other folder in the FTP server.
My C# ftp client should be able to flexibily change current working folder
as requested by the user.

Below is my coding that i use to connect to the FTP server, TQ :

using System;
using System.Collections.Generic;
using System.Text;
using SeasideResearch.LibCurlNet;

namespace ftpcmd
    class ftp
        static void Main(string[] args)
            //Init global curl library

            //Create Easy handle
            Easy easy = new Easy();

            //Create FTP command handle
            Slist slist = new Slist();

            //Get Returned messages from server
            Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData);
            easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);

            //Debug Function
            Easy.DebugFunction df = new Easy.DebugFunction(OnDebug);
            easy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df);

            //Set verbose whatever messages returned to true
            easy.SetOpt(CURLoption.CURLOPT_VERBOSE, true);

            //Login FTP

            //FTP Url

            // use passive FTP, if it's available
            easy.SetOpt(CURLoption.CURLOPT_FTP_USE_EPSV, true);

            //Set return unix parameter (newline) as vbcrlf
            easy.SetOpt(CURLoption.CURLOPT_CRLF, true);

            //Get folder list
            easy.SetOpt(CURLoption.CURLOPT_FTPLISTONLY, true);

            //Append FTP command
            //slist.Append("cwd /pub");
            //slist.Append("cwd /pub/incoming");
            //easy.SetOpt(CURLoption.CURLOPT_QUOTE, slist);

            //Execute FTP connection

            //Cleanup slist content (FTP command)

            //Cleanup curl easy handle

            //Global cleanup curl

            //Wait before closing console
            String wait = Console.ReadLine();

        public static Int32 OnWriteData(Byte[] buf, Int32 size, Int32 nmemb,
            Object extraData)
            Console.Write("Messages : " +
            return size * nmemb;

        public static void OnDebug(CURLINFOTYPE infoType, String msg, Object

Received on 2006-04-12