ASP.Net怎么读取远程服务器上的文件的名称 ASP.net Web程序发布在A服务器上,但是文件File的存储在B服务器上的D盘,Web程序怎么样读到最后更新文件File,并且取她的文件名?同时怎么读取这个文件,以供Web端客户下载?请高手提点,最好有列子或者源码,本人是新手 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Web程序怎么样读到最后更新文件File最后更新是?遍历文件夹 取所有附件。#region 文件下载 public bool DownLoadFile(string localPath, string hostURL, int byteCount, string userID, long cruuent) { bool result = true; string tmpURL = hostURL; byteCount = byteCount * 1024; hostURL = tmpURL + "&npos=" + cruuent.ToString(); System.IO.FileStream fs; fs = new FileStream(localPath, FileMode.OpenOrCreate); if (cruuent > 0) { //偏移指针 fs.Seek(cruuent, System.IO.SeekOrigin.Current); } System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(hostURL); if (cruuent > 0) { request.AddRange(Convert.ToInt32(cruuent)); //设置Range值 } try { //向服务器请求,获得服务器回应数据流 System.IO.Stream ns = request.GetResponse().GetResponseStream(); byte[] nbytes = new byte[byteCount]; int nReadSize = 0; nReadSize = ns.Read(nbytes, 0, byteCount); while (nReadSize > 0) { fs.Write(nbytes, 0, nReadSize); nReadSize = ns.Read(nbytes, 0, byteCount); } fs.Close(); ns.Close(); } catch(Exception ex) { LOG.Error("下载" + localPath + "的时候失败!" + "原因是:" + ex.Message); fs.Close(); result = false; } return result; } #endregion server.mappath("~/然后文件夹") 你应该在更新服务器上放个xml文件存最新发布的程序版本号每次客户端执行更行前都下载这个xml文件客户端比较版本号 不是最新就下载指定的更新压缩包 解压覆盖 获取网站的cookie 求助:为什么神奇的IE8在提交表单到一般处理程序后会显示Internet Explorer 无法显示该网页 我已经晕了,不晕的给我解释一下吧 在线等:xp+sp2 为什么装不上 SQL express edition(SQL 2005也是这样)? 急啊 For Next循环问题 我将文件存入数据库,怎样读出来? asp.net工资? 树状控件的页面跳转问题。在线等带! javascript连接 asp.net word操作问题 [急]asp.net Createuserwizard 添加验证码问题 伪静态网址直接搜索可以搜到但是site不到是怎么回事?
public bool DownLoadFile(string localPath, string hostURL, int byteCount, string userID, long cruuent)
{
bool result = true;
string tmpURL = hostURL;
byteCount = byteCount * 1024;
hostURL = tmpURL + "&npos=" + cruuent.ToString();
System.IO.FileStream fs;
fs = new FileStream(localPath, FileMode.OpenOrCreate);
if (cruuent > 0)
{
//偏移指针
fs.Seek(cruuent, System.IO.SeekOrigin.Current);
}
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(hostURL);
if (cruuent > 0)
{
request.AddRange(Convert.ToInt32(cruuent)); //设置Range值
} try
{
//向服务器请求,获得服务器回应数据流
System.IO.Stream ns = request.GetResponse().GetResponseStream(); byte[] nbytes = new byte[byteCount];
int nReadSize = 0;
nReadSize = ns.Read(nbytes, 0, byteCount);
while (nReadSize > 0)
{
fs.Write(nbytes, 0, nReadSize);
nReadSize = ns.Read(nbytes, 0, byteCount);
}
fs.Close();
ns.Close();
}
catch(Exception ex)
{
LOG.Error("下载" + localPath + "的时候失败!" + "原因是:" + ex.Message);
fs.Close();
result = false;
}
return result;
}
#endregion
每次客户端执行更行前都下载这个xml文件
客户端比较版本号
不是最新就下载指定的更新压缩包 解压覆盖