现在一个文件夹里有很多压缩文件,我需要先解压,然后读取解压后的txt文本内容,文本内容已经是序列化后的格式,现在需要反序列化并导入数据库,然后删除txt文本,下面是我目前的代码
private void button4_Click(object sender, EventArgs e)
{
Person p = new Person();
try
{
if (txtfiles2.Text.Trim() != "")
{
toolStripProgressBar1.Maximum = files2.Length;
for (int i = 0; i < files2.Length; i++)
{
toolStripProgressBar1.Value = i;
string path = files2[i].ToString();
string newpath = path.Remove(path.LastIndexOf("\\") + 1);
UnZip(path, newpath);
string str = null;
using (StreamReader sr = new StreamReader(@"E:\国省道采集数据\Command.txt", System.Text.Encoding.GetEncoding("utf-8")))
{
str = sr.ReadToEnd();
}
var xuliehua = str;
//StreamReader sr = new StreamReader(@"E:\国省道采集数据\Command.txt", Encoding.GetEncoding("gb2312"));
//MessageBox.Show(sr.ToString());
}
toolStripProgressBar1.Value = 0;
MessageBox.Show("解压缩成功!");
}
else
{
MessageBox.Show("警告:请选择要进行批量解压缩的文件!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch { }
}
慕村9548890
相关分类