Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to store the path of the file in local database of  visual studio 2010 and then when i click on the button event it connect to database and display the file to user but database only store the path of the file
Posted

Check This[^]


You can try this
 
Share this answer
 
You can save path like this :

C#
string sPath = Server.MapPath("~/Test.txt");
// IT WILL LOOK LIKE THIS : D:\Folder1\Folder2\Text.txt
// The Sign ~ Represents You Current Web Directory
// SAVE THE PATH TO DATABASE

// While Clicking On Button Get Path From Database and...

if(File.Exists(sPath))
{
   // READ FILE DATA
}
else
{
   // FILE NOT FOUND (MESSAGE)
}
 
Share this answer
 
or this is the right method to read file?

VB
Sub WriteToFile(sender As Object, e As EventArgs)

        Dim fp As StreamReader

        Try
            fp = File.OpenText(Server.MapPath(".\Upload\") & "test.txt")
            txtMyFile.Text = fp.ReadToEnd()
            lblStatus.Text = "File Succesfully Read!"
            fp.Close()
        Catch err As Exception
            lblStatus.Text = "File Read Failed. Reason is as follows

" & err.ToString()
        Finally

        End Try

    End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900