比如:D:\test里有1.txt,2.txt,3.txt......n.txt我想要的格式是,1.zip,2.zip,3.zip而且每一个zip文件里只有一个txt文件,而没有他的上一级的文件夹就教各位大神!!
解决方案 »
- C#编写activex
- 请问各位高手,我要通过80端品访问一个.NET1.1的网站和一个.NTE2.0的网站要怎么设置?
- 求助: 老是提示{“ImageButton”的控件“ibtDone”必须放在具有 runat=server 的窗体标记内}
- 求助:这个页面上的 每个贴子的发贴者信息的状态是怎么搞起来的
- 调用webservice 出错的问题
- timeout expired!!!解决问题立马给分!
- 一简单的正则表达式,是否为整数或者正整数
- 一个SQL语句的问题,在线等.请各位大侠指教!!!!
- 用asp建立聊天室
- ===网站内容本地化(也就是多语言化)=====会的请进。
- 发布后挂出来的网站的运行时出的错误
- asp.net如何连接数据库,求步骤
用cmd语句 实现这个功能,如图:谢谢了!!!!
/// <summary>
/// rar压缩
/// </summary>
/// <param name="file"></param>
/// <param name="spath"></param>
public static void rar(string file, string spath)
{
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process; the_Reg = Registry.ClassesRoot.OpenSubKey("Applications\\WinRAR.exe\\Shell\\Open\\Command"); //win2003 xp
if (the_Reg == null)
{
the_Reg = Registry.ClassesRoot.OpenSubKey("WinRAR\\Shell\\Open\\Command"); //server 2008/win7
} the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.Substring(1, the_rar.Length - 7); if (file.Equals("upload"))
{
the_Info = " a -ep -y " + "No-" + DateTime.Now.ToShortDateString().Replace('/', '-') + "-" + ".rar " + " " + spath;
}
else
{
the_Info = " a -ep -y " + "No-" + DateTime.Now.ToShortDateString().Replace('/', '-') + "-" + ".rar " + " " + spath;
} the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath(@"..\..\" + file);//获取或设置要启动的进程的初始目录。
the_Process = new Process();
the_Process.StartInfo.UseShellExecute = false;
the_Process.StartInfo.RedirectStandardInput = true;
the_Process.StartInfo.RedirectStandardOutput = true;
the_Process.StartInfo.RedirectStandardError = true;
the_Process.StartInfo.ErrorDialog = false;
the_Process.StartInfo.CreateNoWindow = true;
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
the_Process.WaitForExit();
the_Process.Close();
}
那是你方法写的不对
String rarObjStr;
RegistryKey rarRegKey;
Object rarObj;
StringBuilder commandInfo = new StringBuilder();
ProcessStartInfo processInfo;
Process process; rarRegKey = Registry.ClassesRoot.OpenSubKey(@"WinRAR\Shell\Open\Command");
rarObj = rarRegKey.GetValue("");
rarObjStr = rarObj.ToString();
rarRegKey.Close();
rarObjStr = rarObjStr.Substring(1, rarObjStr.Length - 7); commandInfo.Append(" a ");//压缩
if (!File.Exists(toCompress))//非文件-处理所有子文件夹
{
commandInfo.Append(" -r ");
}
if (sizeLimit > 0)//分卷压缩
{
commandInfo.Append("-v");
commandInfo.Append(sizeLimit.ToString());
commandInfo.Append("m "); }
commandInfo.Append(compressedFileFullPath);
commandInfo.Append(" ");
commandInfo.Append(toCompress); processInfo = new ProcessStartInfo();
processInfo.FileName = rarObjStr;
processInfo.Arguments = commandInfo.ToString();
processInfo.WindowStyle = ProcessWindowStyle.Hidden;
processInfo.WorkingDirectory = toCompress;
process = new Process();
process.StartInfo = processInfo;
process.Start();
process.WaitForExit();