会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
玄新-术业有专攻
server端多个文件的压缩 .NET
今天编写程式,内容是把处理过的文件保存到Client端。由于文件较多可能的20个以上,我考虑现压缩,然后把压缩的文件下载到客户端.
压缩代码如下:
int
XRFbeginPage
=
(
int
)Session[
"
XRFbeginPageTemp
"
];
int
sheetAmount
=
(
int
)Session[
"
sheetAmountTemp
"
];
string
rarfileexe
=
@"
D:\Program Files\WinRAR\WinRAR.exe
"
;
string
sourcefile
=
""
;
string
targetfile
=
@"
d:\temp\rar\
"
+
DateTime.Now.Year.ToString()
+
DateTime.Now.Month.ToString()
+
DateTime.Now.Day.ToString()
+
DateTime.Now.Hour.ToString()
+
DateTime.Now.Minute.ToString()
+
DateTime.Now.Second.ToString()
+
"
.rar
"
;
//
choice path
string
shellCommand
=
""
;
//
long result;
int
Rarnumber
=
0
;
int
i;
for
(i
=
XRFbeginPage;i
<=
sheetAmount
-
XRFbeginPage;i
++
)
{
sourcefile
+=
@"
E:\work1025\WebNetProcess\txt\
"
+
i.ToString()
+
"
.txt
"
+
"
"
;
Rarnumber
++
;
}
shellCommand
=
string
.Concat(
"
A -ep1 -inul -y
"
,targetfile,
"
"
,sourcefile);
//
System.Diagnostics.Process.Start(shellCommand);
System.Diagnostics.Process Process1
=
new
System.Diagnostics.Process();
Process1.StartInfo.FileName
=
rarfileexe;
Process1.StartInfo.Arguments
=
shellCommand;
Process1.Start();
while
(
!
Process1.HasExited)
{
}
关键的几行代码是:
System.Diagnostics.Process Process1
=
new
System.Diagnostics.Process();
Process1.StartInfo.FileName
=
rarfileexe;
Process1.StartInfo.Arguments
=
shellCommand;
Process1.Start();
while
(
!
Process1.HasExited)
{
}
压缩完文件之后就可以考虑把压缩的文件下载到客户端
执行外部程序的另外的方法:
AppDomain currentDomain
=
AppDomain.CurrentDomain;
Console.WriteLine(currentDomain.FriendlyName);
AppDomain secondDomain
=
System.AppDomain.CreateDomain(
"
NewAppDomain1
"
);
secondDomain.ExecuteAssembly(
"
testQQClient.exe
"
);
posted on
2006-12-19 11:39
玄新
阅读(
186
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
博客园
首页
联系
管理