生成指定数量的随机文件,但为了方便判断其正确性,需要每发50个就暂停检查一次,请大家帮忙看看
/// <summary>
/// 生成随机文件
/// </summary>
/// <param name="args"></param>
public void filesCreat(string[] args)
{
uint cnt = 0;
string ext = ".bin";
uint fileNum = Convert.ToUInt32(txtFileNumber.Text);
for (cnt = 0; cnt < fileNum; ++cnt)
{
string newName = BuildFileName(txtFilenamePrefix.Text, ext, cnt);
string test1 = Convert.ToString(Utils._creatPath + "\\" + newName);
Console.WriteLine(newName);
//每发送50个文件暂停一次,检查接收目录是否收完,
//计算两者的MD5值存入集合进行比较,若都正确则继续发文件,
//直到发完用户指定的数量,否则,则提示错误
if (fileNum%50==0)
{
}
r.NextBytes(buffer);
using (System.IO.FileStream fs = new System.IO.FileStream(test1, System.IO.FileMode.Create))
{
int maxSize = Convert.ToInt32(txtFileSize.Text) * 1024;
if (!checkBoxSize.Checked)
size = r.Next(1, maxSize);
else
size = maxSize;
fs.Write(buffer, 0, size);
}
}
}