I am using a file system control to display the contents of a text file in a text box. If i use this
<asp:FileUpload ID="txtBoxInput" runat="server" Text="Browse" />
string FilePath = txtBoxInput.PostedFile.FileName;
it will only get the file name e.g. bala.txt.i how to do itD:\New Folder\bala.txt
Instead of managing file uploads, I used a text box to get a 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 a view button instead of a text field to get the path ... Any suggestion
EDIT: mouse 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();
}
}
source
share