用C#做了个在线更新的程序,正常安装时可以正常更新软件,
但是断点续传时出错 提示无法显示错误消息,原因是无法找到包含此错误消息的可选资源程序集
在wince下双击该程序,提示该程序不是正常的WINCE程序
代码如下:
Application.DoEvents();
float percent = 0;
long totalBytes = 0;
try
{
utils.writelogs("start");
HttpWebRequest Myrq = (HttpWebRequest)HttpWebRequest.Create(ServerURL);
HttpWebResponse myrp = (HttpWebResponse)Myrq.GetResponse();
totalBytes = myrp.ContentLength;
utils.writelogs(totalBytes.ToString());
if (prog != null)
{
prog.Maximum = (int)totalBytes;
}
string sPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString());
long totalDownloadedByte=0;
long lStartPos = 0;
System.IO.FileStream fs;
Stream st = myrp.GetResponseStream();
if (File.Exists(sPath + "\\updatefile.CAB"))
{
fs = new FileStream(sPath + "\\updatefile.CAB", FileMode.Open, FileAccess.ReadWrite);//File.OpenWrite(StrFileName);
lStartPos = fs.Length;
fs.Seek(lStartPos, SeekOrigin.Current); //移动文件流中的当前指针