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

    Question

  • Hi all,

     

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

     

     

     

    Thanks,

    Nagaraju.K

    Friday, July 04, 2008 10:50 AM

Answers

All replies

  • Hi,

     

    OpenNETCF provide an OpenNETCF.Net.Ftp namespace.

     

    Take a look at this :-

     

    http://www.opennetcf.com/library/sdf/

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=198443&SiteID=1

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=89964&SiteID=1

     

    Hope this helps.

     

    Paul Diston

     

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

    i think paul given only ftp documentation.

    http://forums.microsoft.com/MSDN/Search/search.aspx?lcid=1033&words=ftp&idx=1&pgsize=10&SiteID=1&localechoice=9&searchscope=forumscope&ForumID=33&ForumGroupID=-1&CSVUserID=

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

    http://community.opennetcf.com/

    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();

    try

    {

    Stream strm = reqFTP.GetRequestStream();

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

    while (contentLen != 0)

    {

    strm.Write(buff, 0, contentLen);

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

    }

    strm.Close();

    fs.Close();

    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.

     

    Thanks,

    Nagaraju.K

    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

    http://community.opennetcf.com/competition/folders/opennetcfnetftp/default.aspx

    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.

     

    Thanks,
    Nagaraju.K

     

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

    http://www.opennetcf.com/Products/SmartDeviceFramework/tabid/65/Default.aspx 

     

    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.
    client.Disconnect();
    Tuesday, October 26, 2010 2:54 PM