wsyeager Posted February 6, 2005 Posted February 6, 2005 Ok, I give up... I've scoured the internet to try and find an example of this, but can't seem to find one. All I want to do is to retrieve the path of a filename. I'm using the HtmlControls.HtmlInputFile control to browse to a file. Once the pathname is in the textbox portion of the control, I then use a linkbutton to actually retrieve the file (based on the pathname in the control). <code> Dim filecontrol As HtmlControls.HtmlInputFile filecontrol = DirectCast(Me.FindControl("ffRequestDoc"), HtmlControls.HtmlInputFile) </code> This works fine if I'm testing on my local machine and the file exists on my local machine. However, I now have the app on another test webserver and when I try and get the pathname of the file, it throws an error saying it can't find the file. Now, I know, it's because the pathname is no longer an absolute path. The question is, how do I get the proper pathname in order to get the file? Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Administrators PlausiblyDamp Posted February 6, 2005 Administrators Posted February 6, 2005 There is no way for a server side asp.net application to directly access the client's HD to either read a file or discover it's location. If you are using the HtmlInputFile control then on the server side you will need to use it's PostedFile property to read the file the browser has uploaded. Given the following asp.net code </pre><form id="Form1" method="post" runat="server"> Text="Button"> </for You should be able to read the files contents with code similar to Dim sr As New System.IO.StreamReader(File1.PostedFile.InputStream) 'can read from file using standard io commands now 'e.g. Dim s As String = sr.ReadLine() Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.