private void togetherFile()//合并文件
{
string strPath = this.TextBox1.Text;
StreamReader frlist=new StreamReader(strPath+"."+"list");
FileStream fw = new FileStream(strPath,FileMode.Append, FileAccess.Write);
string sline;
sline=frlist.ReadLine();
while(sline!=null)
{
FileStream fr = new FileStream(sline,FileMode.Open, FileAccess.Read );
byte [] byteread=new byte[fr.Length] ;
fr.Read(byteread,0,Convert.ToInt32(fr.Length));
foreach(byte bNext in byteread)
fw.WriteByte(bNext) ;
fr.Close();
sline=frlist.ReadLine();
}
frlist.Close();
fw.Close();
}
}
//分割文件
private void cutFile()
{
int i = 0;
string strPath = this.TextBox1.Text;
FileStream file = new FileStream(strPath,FileMode.Open);
BinaryWriter bw = new BinaryWriter(file);
int FileSize = Convert.ToInt32(file.Length)/10;
StreamWriter sw = new StreamWriter(strPath+"."+"list",false);
for(i=1;i<=10;i++)
{
byte[] bt = new byte[FileSize];
file.Read(bt,0,FileSize);
FileStream fw = new FileStream(strPath+"."+i,FileMode.CreateNew,FileAccess.Write);
sw.WriteLine(strPath+"."+i);
foreach(byte btNext in bt)
{
fw.WriteByte(btNext);
}
fw.Close();
}
if(file.Length != file.Position)
{
byte [] byteread=new byte[Convert.ToInt32(file.Length) -FileSize*(i-1)] ;
file.Read(byteread,0,Convert.ToInt32(file.Length) -FileSize*(i-1));
FileStream fw = new FileStream(strPath + "." + i ,FileMode.CreateNew, FileAccess.Write);
sw.WriteLine(strPath +"." + i );
foreach(byte bNext in byteread)
fw.WriteByte(bNext) ;
fw.Close();
}
sw.Flush();
file.Close();
sw.Close();
}
}