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


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

在C#中使用WinRar解压文件            
//声明一个程序信息类
在C#中使用WinRar解压文件
            System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo("winrar.exe");
在C#中使用WinRar解压文件            
//设置外部程序的启动参数(命令行参数)
在C#中使用WinRar解压文件
            Info.Arguments =  " e " + fileName + " " +destinationPath;
在C#中使用WinRar解压文件            
// 隐藏外部程序
在C#中使用WinRar解压文件
            Info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
在C#中使用WinRar解压文件
在C#中使用WinRar解压文件            
//声明一个程序类
在C#中使用WinRar解压文件
            System.Diagnostics.Process Proc ;
在C#中使用WinRar解压文件
在C#中使用WinRar解压文件            
try
{
在C#中使用WinRar解压文件                
//启动外部程序
在C#中使用WinRar解压文件
                Proc = System.Diagnostics.Process.Start(Info);
在C#中使用WinRar解压文件            }

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

在C#中使用WinRar解压文件
在C#中使用WinRar解压文件            
//无限期地等待关联进程退出
在C#中使用WinRar解压文件
            Proc.WaitForExit();
在C#中使用WinRar解压文件            
return true;
在C#中使用WinRar解压文件        }

在C#中使用WinRar解压文件
在C#中使用WinRar解压文件    }

在C#中使用WinRar解压文件

相关文章:

  • 2022-12-23
  • 2021-06-03
  • 2021-09-28
  • 2021-06-19
  • 2021-10-30
  • 2021-06-06
  • 2021-11-30
猜你喜欢
  • 2022-12-23
  • 2021-08-17
  • 2022-01-13
  • 2021-10-13
  • 2022-02-21
  • 2022-12-23
  • 2021-06-15
相关资源
相似解决方案