网上有个用opennetcf的例子,不过是c#,你转过来就ok了。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenNETCF.Net.Ftp;
using System.IO;
using System.Net;
namespace DeviceApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
commandWriter.Write(cmd);
commandWriter.Flush(); // We MUST flush before we start reading from both response and request
// Opening the data connection, this must be done before we issue the command.
Stream ftpResponseStream = ftpWebRequest.GetResponse().GetResponseStream();
BinaryWriter dataWriter = new BinaryWriter(ftpResponseStream);
// Prepare to send commands to the server.
// Set transfer type to IMAGE (binary).
// Reading the request output
//responseReader = new StreamReader(ftpRequestStream);
//responseString = responseReader.ReadToEnd();
// Write the command to the request stream.
// Reading the request output
//responseString = responseReader.ReadToEnd();
// Allocate buffer for the data, which will be written in blocks.
int bufsize = 1024;
byte[] buf = new byte[bufsize];
int xcount;
while ((xcount = fileReader.Read(buf, 0, bufsize)) > 0) {
// Send next buffer over the data connection.
dataWriter.Write(buf, 0, xcount);
Array.Clear(buf, 0, bufsize);
}
fileReader.Close();
filestream.Close();
dataWriter.Close();
//responseReader.Close();
return true;
} catch (Exception ex) {
throw ex;
}
}
}
}