简体   繁体   English

上传的文件是否采用制表符分隔格式

[英]Whether a file uploaded is in tab-delimited format

I am using ASP.Net fileupload control to allow users to upload a tab-delimited file with a txt extension. 我正在使用ASP.Net文件上传控件,以允许用户上传带有txt扩展名的制表符分隔的文件。

How would I make sure in code that the file is tab-delimited? 如何在代码中确保文件以制表符分隔? I am using C#. 我正在使用C#。

Currently, I am using following code. 目前,我正在使用以下代码。

        StreamReader stream = null;
        if (FileUpload1.HasFile)
        {
            if (FileUpload1.FileName.EndsWith("txt") )
            {
                string filename = Path.Combine(Server.MapPath("~/files"), Guid.NewGuid().ToString() + ".txt");
                FileUpload1.PostedFile.SaveAs(filename);
                Session["UploadedFileName"] = filename;
                stream = new StreamReader(FileUpload1.PostedFile.InputStream);
            }
            else
            {
                lblMessage.Text = "File format not supported. Please use a tab delimited .txt file.";
                pnlMessage.Visible = true;
                return;
            }
        }
        else
        {
            lblMessage.Text = "You must select a file to upload.";
            pnlMessage.Visible = true;
            return;
        }

服务器控件一次只能上传一个文件,不支持上传多个文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM