首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

那位大侠帮忙见见 c# 解压出现为找到解压文件

2012-09-09 
那位大侠帮忙看看 c# 解压出现为找到解压文件C# code//解压public bool DoUnPack(){bool r false// str

那位大侠帮忙看看 c# 解压出现为找到解压文件

C# code
     //解压        public bool DoUnPack()        {            bool r = false;           // string strR = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "update"+"//";            string strR = Application.StartupPath + "//" + "update";             //MessageBox.Show(strR);            Console.WriteLine("开始解压......");            RegistryKey reg;            string rarPath;            Process process = new Process();            try            {                reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");                rarPath = reg.GetValue("").ToString();                rarPath = rarPath.Substring(1, rarPath.Length - 7);                process.StartInfo.FileName = rarPath;                process.StartInfo.CreateNoWindow = true;                process.StartInfo.UseShellExecute = false;                // -0+ 如果已经存在则覆盖                process.StartInfo.Arguments = string.Format(" x -o+ {0} {1}", strR, Application.StartupPath + "//");//这里是命令行请参考winrar的说明                //开始解压                process.Start();                while (!process.HasExited)                {                }                //进程终止                if (process.HasExited)                {                    int exitCode = process.ExitCode;                    if (exitCode == 0)                    {                        Console.WriteLine("{0} 正常完成", exitCode.ToString());                        r= true;                    }                    else                    {                        Console.WriteLine("{0} 正常完成", exitCode.ToString());                                            }                }                Console.WriteLine("解压完成");                return r;            }            catch (Exception ex)            {                //MessageBox.Show("123");              throw ex;            }            finally            {                //释放资源                process.Close();                            }        }


 安装路径 有update.rar 文件 但提示找不到压缩文件 求大侠指点


[解决办法]
你看看 rarPath 是什么内容,不一定你就能从注册表中读到数据,或者你将字符串处理错误
[解决办法]
是否考虑过windows7之类的用户安全权限,读取注册表要不要管理员权限?

热点排行