我想使用“打开文件”对话框打开文件。如果打开的文件长度是94的倍数,我想打开该文件,否则我想抛出一个错误消息
最佳答案
if(new FileInfo(path).Length % 94 == 0)
{
using(var reader = new StreamReader(path))
{
...
}
}
else
throw new ArgumentException("File-length not multiple of 94", "path");