Click here to Skip to main content
Sign Up to vote bad
good
See more: HTML
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 25-Dec-12 12:08pm


3 solutions

Check This[^]
 

You can try this
  Permalink  
You can save path like this :
 
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)
}
  Permalink  
or this is the right method to read file?
 
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
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 453
1 Ron Beyer 316
2 Tadit Dash 243
3 OriginalGriff 236
4 samadhan_kshirsagar 173
0 Sergey Alexandrovich Kryukov 7,061
1 Prasad_Kulkarni 3,830
2 OriginalGriff 3,620
3 _Amy 3,370
4 CPallini 3,074


Advertise | Privacy | Mobile
Web04 | 2.6.130619.1 | Last Updated 26 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid