string DirectoryName = Path.GetDirectoryName(fpdcheck.PostedFile.FileName); //获取文件所在目录
string Extension = Path.GetExtension(fpdcheck.PostedFile.FileName); //获取扩展名
if (Extension != ".csv")
{
lblMsg.Text = “有错误”
lblMsg.ForeColor = Color.Red;
return;
}
int columnCount = 0;
int FileLen = fpdcheck.PostedFile.ContentLength;
byte[] input = new byte[FileLen];
System.IO.Stream UpLoadStream = fpdcheck.PostedFile.InputStream;
UpLoadStream.Read(input, 0, FileLen);
UpLoadStream.Position = 0;
using ( System.IO.StreamReader sr = new System.IO.StreamReader(UpLoadStream, System.Text.Encoding.Default))
{
while (sr.Peek() > 0)
{
string strData = sr.ReadLine();
//创建标题列