Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3395866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:20:23+00:00 2026-05-18T04:20:23+00:00

I am using a fileupload control to display the contents of a text file

  • 0

I am using a fileupload control to display the contents of a text file in a textbox..if i use this

<asp:FileUpload ID="txtBoxInput" runat="server" Text="Browse" />

string FilePath = txtBoxInput.PostedFile.FileName;

it will get only the file name like bala.txt.i need like this D:\New Folder\bala.txt

Instead of fileupload control i have used textbox to get the path like this D:\New Folder\bala.txt

<asp:TextBox ID="txtBoxInput" runat="server" Width="451px"></asp:TextBox>

string FilePath = txtBoxInput.Text;

But i need browse button instead of textbox to get the path…Any Suggestion??

EDIT:My button click event

protected void buttonDisplay_Click(object sender, EventArgs e)
{
    string FilePath = txtBoxInput.PostedFile.FileName;
    if (File.Exists(FilePath))
    {
        StreamReader testTxt = new StreamReader(FilePath);
        string allRead = testTxt.ReadToEnd();
        testTxt.Close();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:20:23+00:00Added an answer on May 18, 2026 at 4:20 am

    You can get the file name and path from FileUpload control only when you are in debug mode but when you deployed your app. in server then you cant because that is your client address which you are trying to access by server side code.

    protected void Button1_Click(object sender, EventArgs e)
    {
        string filePath,fileName;
        if (FileUpload1.PostedFile != null)
        {
            filePath = FileUpload1.PostedFile.FileName; // file name with path.
            fileName = FileUpload1.FileName;// Only file name.
        }
    }
    

    If you really want to change properties or rename client file then you can save file on server on temp folder then you can do all thing which you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m using asp.net 2.0 without AJAX. The file path in the fileupload control
I want to get the type of file uploaded using the ASP.NET FileUpload control.
Greetings! I am using the ASP.NET FileUpload control to allow users to upload text
Here is my code to post the file. I use asp fileupload control to
I am uploading a file using a simple FileUpload control named theFile (ASP.NET). I'm
I want to upload a file using FileUpload Control in asp.net and i'm using
I am using FileUpload control to facilitate Image file upload on my website. I
I want to validate asp FileUpload Control using in asp.net. That should accept only
Im trying to use the fileupload control. Im using Visual Web Developer Express on
I am using the fileupload control in asp.net. I want the browser to only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.