Browse Directories for save location
Hello!
I need code that will allow the user to do the following:
1. Select a browse button and choose the folder they want to save a file once the exe file at the end of the program runs
2. Display the folder location the user selected in the textbox next to it
Basically this is a save dialog box but since this is a web application and not a web form I can not use the dialog boxes.
Here is the code I have so far, I am thinking its not right so please help me with this!
Protected Sub Browse_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Browse.Click
Dim FilePath As String = ("C:\Users\Public\Documents")
Dim targetFile As System.IO.FileInfo = New System.IO.FileInfo(FilePath)
If targetFile.Exists Then
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" + targetFile.Name)
Response.AddHeader("Content-Length", targetFile.Length.ToString)
Response.ContentType = "application/octet-stream"
Response.WriteFile(targetFile.FullName)
End If
End Sub
Thank you
sastokes
Junior Poster in Training
50 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
What type of control is your browse?
If it is of type "File" (in HTML), you will get a dialog box
<body>
<form id="form1" runat="server">
<div>
<input id="fileIn" type="file" name="fileIn" runat="server"/>
</div>
</form>
</body>
...but are you trying to reference on the on the server or the client machine?
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402