求教!VB.NET 语言在windows mobile下怎样实现客户端和服务器之间的文件的上传和下载呢?

ESEVV 2010-03-08 03:55:15
VB.NET 语言在windows mobile下怎样实现客户端和服务器之间的文件的上传和下载呢?
谢谢各位大侠了。
...全文
216 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
88csdn 2010-03-09
  • 打赏
  • 举报
回复
FTP和HTTP都是很好的选择
ESEVV 2010-03-09
  • 打赏
  • 举报
回复
结贴后还可以回复吗?

test
ESEVV 2010-03-09
  • 打赏
  • 举报
回复
谢谢各位的回答了。
昨晚下雪了,好冷哦!

我要结贴了哦!

全速前行 2010-03-09
  • 打赏
  • 举报
回复
网上有个用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();
}

private void button1_Click(object sender, EventArgs e)
{
NetworkCredential myCredential=new NetworkCredential("baodao","*****");
if (UploadFile("baodao@211.95.73.93:2122", "testPath", "Sunset.jpg", myCredential))
MessageBox.Show("seccess");
}

public static bool UploadFile(string host, string directory, string filePathName, ICredentials credentials)
{

Uri uri = null;

string fileName = Path.GetFileName(filePathName);
//if (directory == null)
uri = new Uri(string.Format(@"ftp://{0}", host));
//else
//uri = new Uri(string.Format(@"ftp://{0}/{1}/", host, directory));
try {
FtpRequestCreator creator = new FtpRequestCreator();
WebRequest.RegisterPrefix("ftp:", creator);
FtpWebRequest ftpWebRequest = (FtpWebRequest)WebRequest.Create(uri);
//WebRequest ftpWebRequest = WebRequest.Create(uri);
//FtpWebRequest ftpWebRequest = new FtpWebRequest(uri);
ftpWebRequest.Credentials = credentials;
// Getting the Request stream



FileStream filestream = new FileStream(filePathName, FileMode.Open);
BinaryReader fileReader = new BinaryReader(filestream);


Stream ftpRequestStream = ftpWebRequest.GetRequestStream();
StreamWriter commandWriter = new StreamWriter(ftpRequestStream);

//StreamReader responseReader = new StreamReader(ftpRequestStream);

// Just ignore the result, but read it.
//String responseString = responseReader.ReadToEnd();

// Open the input file. If the file does not exist, it's an error.


// Create the reader for the local file data.


commandWriter.Write("TYPE I\r\n");
commandWriter.Flush();


String cmd = "stor " + @"\" + directory + @"\" + fileName + "\r\n";


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;
}
}
}
}
Defonds 2010-03-09
  • 打赏
  • 举报
回复
引用楼主 esevv 的回复:
VB.NET 语言在windows mobile下怎样实现客户端和服务器之间的文件的上传和下载呢?
谢谢各位大侠了。
用http
Jake_Lin 2010-03-09
  • 打赏
  • 举报
回复
使用ActiveSync来拷贝。 Windows Embedded CE和Windows Mobile下ActiveSync开发
希望对你有用。
dyw 2010-03-08
  • 打赏
  • 举报
回复
用http协议很常见
ESEVV 2010-03-08
  • 打赏
  • 举报
回复
继续顶~~~~


回复内容 回复内容太短了!
ESEVV 2010-03-08
  • 打赏
  • 举报
回复
楼上的,可不可以具体一点?
要不然,我给贴点例子呀?

谢谢了
xuzhaoyue1 2010-03-08
  • 打赏
  • 举报
回复
用文件流方式上传,调用WS
ESEVV 2010-03-08
  • 打赏
  • 举报
回复
自己顶············
ESEVV 2010-03-08
  • 打赏
  • 举报
回复
具体是这样的。

客户端是个手机,服务器是个PC,
然后用.net 编写手机的应用程序,去实现从服务器上下载文件。

谢谢楼上哦
世外涛缘 2010-03-08
  • 打赏
  • 举报
回复
可以使用FTP,可以使用Socket,可以使用WebService。
楼主问的问题太宽泛了,建议细化问题再来提问。
ESEVV 2010-03-08
  • 打赏
  • 举报
回复
自己沙发 回复内容 回复内容太短了!

7,655

社区成员

发帖
与我相关
我的任务
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
  • Windows客户端开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧