我正在尝试使用7zG.exe的命令行压缩/ 7z文件夹.我的代码适用于文件,但不适用于文件夹.有人可以用7z命令行来压缩文件夹,告诉我正确的方法吗?以下是仅适用于文件的示例代码.每当我尝试运行此代码时,7zip会显示一个消息框,说"参数无效"
string sourceName = "Folder\Folder1";
string targetName = "Example.gz";
// 1
// Initialize process information.
//
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = "7zG.exe";
// 2
// Use 7-zip
// specify a=archive and -tgzip=gzip
// and then target file in quotes followed by source file in quotes
//
p.Arguments = "a -tgzip \"" + targetName + "\" \"" + sourceName + "\" -mx=9";
p.WindowStyle = ProcessWindowStyle.Hidden;
// 3.
// Start process and wait for it to exit
//
Process …Run Code Online (Sandbox Code Playgroud) 在我的SQL数据库中,我有一张美国每个州的表格.用户可以在不同的状态下创建多个页面.每个表都有一个"UserID"列,该列始终与登录用户匹配.如何在多个表中搜索"UserID"?
string sqlquery = "SELECT * FROM[all tables] WHERE @UserID ='" + userID.Text + "'";
SqlConnection conn1 = new SqlConnection(connString);
SqlCommand comm1 = new SqlCommand(sqlquery, conn1);
SqlDataReader DR1 = comm1.ExecuteReader();
if (DR1.Read())
{
Textbox1.Text = DR1.GetValue(0).ToString();
}
Run Code Online (Sandbox Code Playgroud) 有没有办法使用SHA1来散列包含其中所有内容的文件夹?我能够使用MD5做到这一点,但我担心MD5遭受的冲突.我正在尝试构建一个应用程序来检查本地文件,以查看它们是否与使用哈希的在线版本匹配.
这是我在MD5中使用的代码:
var path = leftCheckTextbox.Text;
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)
.OrderBy(p => p).ToList();
MD5 md5 = MD5.Create();
for (int i = 0; i < files.Count; i++)
{
string file = files[i];
string relativePath = file.Substring(path.Length + 1);
byte[] pathBytes = Encoding.UTF8.GetBytes(relativePath.ToLower());
md5.TransformBlock(pathBytes, 0, pathBytes.Length, pathBytes, 0);
byte[] contentBytes = File.ReadAllBytes(file);
if (i == files.Count - 1)
md5.TransformFinalBlock(contentBytes, 0, contentBytes.Length);
else
md5.TransformBlock(contentBytes, 0, contentBytes.Length, contentBytes,0);
}
leftHash = BitConverter.ToString(md5.Hash).Replace("-", "").ToLower();
Run Code Online (Sandbox Code Playgroud) 我想使用.split函数或任何允许我读取文本文件并获取应用程序中创建的值并将它们放入文本文件中拆分符号所在区域的函数.
例如:示例文本文件:template.txt我的名字是*.我是*岁.我出生于*.
textbox1 = Jim
textbox2 = 25
textbox3 = 08/14/2012
我希望将textbox1到textbox3的值添加到一个新的文本文件中,其中包含来自"*"符号的template.txt中的行.有什么想法吗?