Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the path to a file on a users machine

Status
Not open for further replies.

prover

Programmer
Sep 12, 2001
54
US
This may be simple but it eascapes me...

What i'm doing is reading data from Excel to a datareader. I don't have a problem with doing that. My problem is trying to point to the Excel file on a user local machine. If i hard code the path i'm fine. I was playing around with the fileupload control but every time i try to read the path it points to the wrong path. My research found that it is a security issue. Is it possible to point to a file on a users pc and read from it?

Code:
Dim strName As String
        strName = Path.GetFileName(txtExcelFile.PostedFile.FileName)

        Me.Label1.Text = Path.GetFullPath(strName).ToString

        Dim DBConnection = New Data.OleDb.OleDbConnection( _
                  "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                  "Data Source=C:/Test/" & strName & ";" & _
                  "Extended Properties=""Excel 8.0;HDR=Yes""")
        DBConnection.Open()

        Dim SQLString As String = "SELECT * FROM [elecInfo$]"
        Dim DBCommand = New Data.OleDb.OleDbCommand(SQLString, DBConnection)
        Dim DBReader As Data.IDataReader = DBCommand.ExecuteReader()
        gv.DataSource = DBReader
        gv.DataBind()
        DBReader.Close()
        DBConnection.Close()

 
Is it possible to point to a file on a users pc and read from it?
Nope. Imagine if I could read files on your system when you browsed my web site...

You will have to get the user to upload the file, save it to the server and then read it.




-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Yup your right. No playing out of the sandbox!

TY

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top