froster

博客园 首页 新随笔 联系 订阅 管理

给我在银行的同学写了好几个文本文件的数据提取小程序,其中,源文件都是.zip压缩文件。将这个东东放上来大家参阅一下。


    public class RarFile
    
{
        
public static bool UnCompress(string fileName, string destinationPath)
        
{
            
if (!System.IO.File.Exists(fileName))
            
{
//                MessageBox.Show("没有找到压缩文件"  + fileName,"错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return false;
            }

            
//声明一个程序信息类
            System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo("winrar.exe");
            
//设置外部程序的启动参数(命令行参数)
            Info.Arguments =  " e " + fileName + " " +destinationPath;
            
// 隐藏外部程序
            Info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

            
//声明一个程序类
            System.Diagnostics.Process Proc ;

            
try
            
{
                
//启动外部程序
                Proc = System.Diagnostics.Process.Start(Info);
            }

            
catch(System.ComponentModel.Win32Exception)
            
{
                MessageBox.Show(
"系统找不到WinRar的程序文件!\n请先安装WinRar程序。""错误",MessageBoxButtons.OK, MessageBoxIcon.Error);
                
return false;
            }


            
//无限期地等待关联进程退出
            Proc.WaitForExit();
            
return true;
        }


    }

posted on 2005-03-30 20:11  大牛  阅读(1352)  评论(1编辑  收藏  举报