如何停止清除asp.net中FileUpload控件的URL [英] How to stop clearing the URL of FileUpload control in asp.net

查看:87
本文介绍了如何停止清除asp.net中FileUpload控件的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个FileUpload控件,一个Button和TextBox.单击FileUpload控件时,我们可以获得文件URl.之后,单击按钮",将垂直文件内容"导入到TextBox中.

问题是单击按钮"将数据导入TextBox时,同时清除了URL.如何停止清除fileUpload控件中的Url.

Hi Guys, I have a one FileUpload Control , one Button and TextBox.When clicking on the FileUpload control,we can getting the file URl. After that clicking the Button getting the perticular file Content into TextBox.

Problem is when clicking the Button getting the data into TextBox and same time URL also cleared. How to Stop the clearing the Url in fileUpload control.

protected void btnGet_Click(object sender, EventArgs e)
   {

       if (FUBrowse.HasFile)
       {
           string path = FUBrowse.PostedFile.FileName;
           this.FUBrowse.SaveAs(path);
           this.txtJobDescription.Text = ShowContent(path);
       }

   }
   public string ShowContent(string path)
   {
       string strInput = "";
       string GetStream = "";

       if (File.Exists(path))
       {
           StreamReader sr = new StreamReader(path, UnicodeEncoding.GetEncoding("UTF-8"));
           strInput = sr.ReadLine();
           while (strInput != null)
           {
               GetStream += strInput;
               strInput = sr.ReadLine();
           }
           sr.Close();
       }
       else
       {
           Response.Write("file does not exist!");
       }
       return GetStream;
   }




请任何人帮助我.




Please any one Help me.

推荐答案

亲爱的,

您可以通过
解决此问题
dear,

You can solve this issue by
string path = FUBrowse.PostedFile.FileName;
            string serverPath = HttpContext.Current.Server.MapPath("~/");
            path = serverPath + path;
            this.FUBrowse.SaveAs(path);
            this.txtJobDescription.Text = ShowContent(path);


这篇关于如何停止清除asp.net中FileUpload控件的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆