java 解压cab文件_解压缩.cab文件,然后使用.net mobile 3.5在Windows CE 6.0上关闭正在运行的进程...

在Windows CE 6.0平台上,一个使用.cab文件进行自动更新的程序遇到了问题。程序能够检测到更新并开始下载,但在尝试解压缩下载的.cab文件时失败。错误出现在解压缩过程中,可能是由于文件正在被使用导致。在尝试启动更新过程时,程序会闪现一个窗口并可能导致系统挂起,需要重启。问题在于如何在不重启设备的情况下关闭当前程序并正确启动.cab文件的安装。
摘要由CSDN通过智能技术生成

我有一个Windows CE 6.0程序,它使用.cab文件进行安装 . 它包含http://msdn.microsoft.com/en-us/library/aa446487.aspx的指南,以支持自动自我更新 .

程序可以检查更新就好了,它会按照它应该下载更新,但是当我尝试将它解压缩刚下载的.cab文件时,它会失败 .

这是我的代码:

void ResponseReceived(IAsyncResult res)

{

try

{

_mResp = (HttpWebResponse)_mReq.EndGetResponse(res);

}

catch (WebException ex)

{

MessageBox.Show(ex.ToString(), "Error");

return;

}

// Allocate data buffer

_dataBuffer = new byte[DataBlockSize];

// Set up progrees bar

_maxVal = (int)_mResp.ContentLength;

pgbDownloadBar.Invoke(new EventHandler(SetProgressMax));

// Open file stream to save received data

_mFs = new FileStream(@"\Application\CCOptimizerSetup.cab",

FileMode.Create);

// Request the first chunk

_mResp.GetResponseStream().BeginRead(_dataBuffer, 0, DataBlockSize,

OnDataRead, this);

}

void OnDataRead(IAsyncResult res)

{

// How many bytes did we get this time

int nBytes = _mResp.GetResponseStream().EndRead(res);

// Write buffer

_mFs.Write(_dataBuffer, 0, nBytes);

// Update progress bar using Invoke()

_pbVal += nBytes;

pgbDownloadBar.Invoke(new EventHandler(UpdateProgressValue));

// Are we done yet?

if (nBytes > 0)

{

// No, keep reading

_mResp.GetResponseStream().BeginRead(_dataBuffer, 0,

DataBlockSize, OnDataRead, this);

}

else

{

// Yes, perform cleanup and update UI.

_mFs.Close();

_mFs = null;

Invoke(new EventHandler(AllDone));

}

}

private void AllDone(object sender, EventArgs e)

{

Cursor.Current = Cursors.Default;

DialogResult dialogresult = MessageBox.Show(@"CCOptimizer has finished downloading. Open now?", "Download complete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

switch (dialogresult)

{

case DialogResult.OK:

Application.Exit();

Dispose();

Close();

Invoke(new EventHandler(StartProcess));

break;

case DialogResult.Cancel:

Form1 oForm = new Form1();

oForm.Show();

Hide();

break;

}

}

private void StartProcess(object sender, EventArgs e)

{

Process.Start(@"\Application\CCOptimizerSetup.cab", null);

}

它不起作用 . 无论我在哪里放置 StartProcess() 的调用,要么只是关闭而没有消息,要么在解压缩过程中出现错误,我正在尝试更新的其中一个文件仍在使用中 . 在调试过程中,它只是停止程序 . 如果我尝试安装的版本,它会非常短暂地闪烁一个窗口,然后在WaitCursor旋转的情况下锁定机器并需要重新启动,尽管之后它可以安装得很好 .

如何关闭当前程序并打开.cab文件而无需重新启动计算机?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值