Uploading file to ftp server from .net windows mobile application.


  • Hi all,


    Please let me know if anybody is having idea how to upload a file from .net windows mobile application to ftp server.






    Friday, July 04, 2008 10:50 AM


All replies

  • Hi,


    OpenNETCF provide an OpenNETCF.Net.Ftp namespace.


    Take a look at this :-



    Hope this helps.


    Paul Diston


    Friday, July 04, 2008 11:07 AM
  • Hi

    i think paul given only ftp documentation.

    But you can download the ftp sample and libaray from the following link.

    Here you can dwonlaod free lib.

    Thank you

    Friday, July 04, 2008 2:13 PM
  • Hi,

    Thank you for reply. Actually I wrote the following code.


    string fileName = "D:\\HttpWebrequest.txt";

    FileInfo fileInf = new FileInfo(fileName);

    FtpWebRequest reqFTP;

    reqFTP = (FtpWebRequest)FtpWebRequest.Create(<ftpserver> + fileInf.Name);

    reqFTP.Credentials = new NetworkCredential(username, password);

    reqFTP.KeepAlive = false;

    reqFTP.Method = WebRequestMethods.Ftp.UploadFile;

    reqFTP.UseBinary = true;

    reqFTP.ContentLength = fileInf.Length;

    int buffLength = 2048;

    byte[] buff = new byte[buffLength];

    int contentLen;

    FileStream fs = fileInf.OpenRead();



    Stream strm = reqFTP.GetRequestStream();

    contentLen = fs.Read(buff, 0, buffLength);

    while (contentLen != 0)


    strm.Write(buff, 0, contentLen);

    contentLen = fs.Read(buff, 0, buffLength);




    FtpWebResponse ftpres = (FtpWebResponse)reqFTP.GetResponse();


    catch (Exception ex)


    MessageBox.Show(ex.Message, "Upload Error");



    It is working in windows applications, but it is not working in windows mobile application because "FtpWebRequest" class is not available.


    Please let me know which class i should use to achive the above functionality.




    Friday, July 04, 2008 2:33 PM
  • Hi

    That y we spent time and told you use the opennetCf ftp lib.

    because of .net cf  haven't ftp supportable class.

    Please use the Opennet lib

    Thank you
    Saturday, July 05, 2008 10:34 AM
  • Hi,

    Thank you for your reply.

    I downloaded "opennetCf ftp lib" from that site.It looks good.


    But they didn't mention whether it is free source or we do need to pay.


    Please let me know whether it is free source or not.




    Saturday, July 05, 2008 11:34 AM
  • Read this yourself: 


    And before or after you install the SDF, read the license agreement.

    Monday, July 07, 2008 6:06 AM
  • You may need a component for .NET Compact Framework like the Ultimate FTP for .NET CF. The following code is from its FTP webblog :

    // Create a new instance.
    Ftp client = new Ftp();
    // Connect to the FTP server.
    client.Connect( "localhost" );
    // Authenticate.
    client.Authenticate( "test" , "test" );
    // ...
    // Upload all files and subdirectories from local folder 'c:\temp' to the remote dir '/temp'
    client.UploadFiles( "c:\\temp" , "/temp" );
    // Upload all directories, subdirectories, and files that match the specified search pattern from local folder 'c:\myfolder2' to remote folder '/myfolder2'.
    client.UploadFiles( "c:\\myfolder2" , "/myfolder2" , "*.cs" );
    // or you can simply put wildcard masks in the source path, our component will automatically parse it.
    // upload all *.css files from local folder 'c:\myfolder2' to remote folder '/myfolder2'.
    client.UploadFiles( "c:\\myfolder2\\*.css" , "/myfolder2" );
    // Upload *.cs and *.vb files from local folder 'c:\myfolder2' to remote folder '/myfolder2'.
    client.UploadFiles( "c:\\myfolder2\\*.cs;*.vb" , "/myfolder2" );
    // ...
    // Disconnect.
    Tuesday, October 26, 2010 2:54 PM