private string RunCmd(string command)
{
//实例一个Process类,启动一个独立进程
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c "+"\""+System.Windows.Forms.Application.StartupPath+"\\r ar.exe" +"\""+ command; //设定程式执行参数
p.StartInfo.UseShellExecute = false; //关闭Shell的使用
p.StartInfo.RedirectStandardInput = true; //重定向标准输入
p.StartInfo.RedirectStandardOutput = true; //重定向标准输出
p.StartInfo.RedirectStandardError = true; //重定向错误输出
p.StartInfo.CreateNoWindow = true; //设置不显示窗口
p.Start(); //启动
string retstr=p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
return retstr; //从输出流取得命令执行结果
}
/// <summary>
/// 获得RAR信息
/// </summary>
/// <param name="rar_path">包文件路径</param>
/// <returns></returns>
private Hashtable CheckRar(string rar_path)
{
string strcmd1 = string.Format(" lb {0} ", rar_path);
string outcmd_string1 = RunCmd(strcmd1).Replace("\r\n", "|");
outcmd_string1 = outcmd_string1.Remove(outcmd_string1.LastIndexOf('|'));
string strcmd2 = string.Format(" l {0} ", rar_path);
string outcmd_string2 = RunCmd(strcmd2);
string[] strfilenames = outcmd_string1.Split('|');
int filecount = strfilenames.Length;
string[] strfilesizes = new string[filecount];
for (int i = 0; i < filecount; i++)
{
string filesize = outcmd_string2.Substring(outcmd_string2.IndexOf(strfilenames[i]) + strfilenames[i].Length).Trim();
filesize = filesize.Substring(0, filesize.IndexOf(" "));
strfilesizes[i] = filesize;
}
Hashtable ht_rar = new Hashtable();
for (int i = 0; i < filecount; i++)
{
ht_rar.Add(strfilenames[i],strfilesizes[i]);
}
return ht_rar;
}
分享到:
相关推荐
读取文件夹里面的压缩包文件 Ionic.Zip.CF.dll cs demo例子
c#读取二进制文件c#读取二进制文件c#读取二进制文件c#读取二进制文件c#读取二进制文件c#读取二进制文件
在众多的RAR文件中搜索特定的文件并解压出来.非常实用的小工具.另外也可了解RAR解压编程
调用方法: ...文件只是一个案例。添加多个可以循环以下代码: zipStream.PutNextEntry(newEntry); StreamUtils.Copy(streamReader, zipStream, buffer); zipStream.CloseEntry(); RAR格式还未测试
C# 读取加密的Excel 文件; 有源码,VS2010开发。 采用的是微软的Microsoft.Office.Interop.Excel, V14.0,来读取加密后的Excle文件。 不是采用第三方控件NPOI读取加密的Excel文件。 开始研究NPOI读取加密的Excel文件...
界面采用的dev,如果没有安装,直接看类也可以的,C#读取dbf文件,文件流方式,不需要任何辅助
C# 读取Autocad DXF文件图形数据 导出excel数据 可以查看
C# 读取数组Json文件
c#读取文件信息 储存到excel里 代码不规范 但是 很容易理解
C#读取BIN文件内容,获取其中数据并显示。用于对BIN文件的操作。
C#读取outlook中msg文件 可以直接读到附件并另存为 读到邮件的主题 联系人 正文
c#读取txt文件,cs文件,html文件,实现用户自定义目录,本程序是vs2008版,2005版需要升级
C# 读取VCT文件内容 Windows编程C# 读取VCT文件内容 Windows编程C# 读取VCT文件内容 Windows编程C# 读取VCT文件内容 Windows编程C# 读取VCT文件内容 ...
C#读取修改Json文件
C#实现选择文件读取文件内容,我们可能要对本地文件进行读取,然后可能取进数据库等,这里只是做了读取文件内容显示出来没有入库操作。
用C#写的文件读取功能,根据文件已读取数据同步显示已读取文件进度条。
C#读写Matlab文件,支持+ Double array+ Single array+ Char array+Structure+ Cell array+ Sparse array+ Int8 array+ UInt8 array + Int16 array+ UInt16 array+ Int32 array+ UInt32 array+ Int64 array+UInt64 ...
C#读取INI文件C#读取INI文件C#读取INI文件C#读取INI文件C#读取INI文件C#读取INI文件C#读取INI文件C#读取INI文件C#读取INI文件C#读取INI文件C#读取INI文件
简单的读取文件信息的C#小程序,主要包含对文件基本信息和文件内容的读取,但仅限于英文读取,中文读取会出现乱码!
c#读取图片文件信息并转换成16进制文本方法.docxc#读取图片文件信息并转换成16进制文本方法.docx