C# 用于生成归档文件的简单脚本arj
以下是代码:C# 用于生成归档文件的简单脚本arj,c#,arj,C#,Arj,以下是代码: string command = string.Empty; DirectoryInfo dInfoForTesting = new DirectoryInfo(@"E:\TestFiles"); FileInfo[] files = dInfoForTesting.GetFiles(); foreach (FileInfo file in files) { string rndPswd = "134"; command = "arj a -m1 -g" + rnd
string command = string.Empty;
DirectoryInfo dInfoForTesting = new DirectoryInfo(@"E:\TestFiles");
FileInfo[] files = dInfoForTesting.GetFiles();
foreach (FileInfo file in files)
{
string rndPswd = "134";
command = "arj a -m1 -g" + rndPswd + " " + file.Name + ".arj " + file.FullName;
Process.Start(@"C:\ARJ_TEST\programming\test\ARJ.EXE", command);
}
我想自动创建受简单密码保护的存档134uisng ARJ archiver。但当我为第一个文件运行此代码时,我看到下图。但是这个文件存在
请帮我理解一下,我做错了什么
编辑:
我已决定重写代码以在文件夹E:\TestFiles
中运行cmd,其中有所有用于测试的文件:
ProcessStartInfo startInfo = new ProcessStartInfo
{
WorkingDirectory = @"E:\TestFiles",
FileName = "cmd.exe",
UseShellExecute = false,
RedirectStandardInput = false
};
foreach (FileInfo file in files)
{
string rndPswd = "134";
command = "arj a -m1 -g" + rndPswd + " " + file.Name + ".arj " + file.Name;
startInfo.Arguments = command;
Process.Start(startInfo);
}
例如,如果我直接从cmd运行命令
arja-m1-g134 10.arj 10
,arj将创建一个存档10.arj
。但是当我为第一个文件(10
)运行代码时,什么都没有发生…其中一个文件的file.FullName
是什么?它是否包含空格?@Amy,例如,在VS12中,我看到E:\\TestFiles\\10
文件名为10
?是的,没有扩展名。好的,命令的确切内容是什么?