| Author: santhosh punnam 10 Jul 2006 | Member Level: Bronze | Rating: Points: 2 |
i will send total code please follow these instructions
take new proj in asp.net and go to html view copy the follwoing code
<HEAD> <TITLE>File Download</TITLE> </HEAD> <body leftMargin="0" topMargin="0" marginwidth="0" marginheight="0"> <form id="frmDownload" method="post" runat="server"> <table cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr> <td align="center"><IMG src="images/up.gif"> </td> </tr> </table> <table width="90%" align="center" border="0"> <tr> <td align="center"> </td> </tr> <tr> <td class="PageHeading" align="center">File Download (VB) </td> </tr> <tr> <td><IMG height="10" src="images/spacer.gif" border="0"></td> </tr> <tr> <td align="center"> <asp:ListBox ID="lstFiles" Runat="server" Rows="6" /> </td> </tr> <tr> <td align="center"> <br> <input id="btnDownload" runat="server" type="button" value="Download" NAME="btnDownload"> </td> </tr> </table> </form> </body>
go to code behind import name space imports System.io
Dim files() As String
page_load
Dim index As Integer
If (Not Page.IsPostBack) Then
'get list of files in the images directory (just for example here)
'files = Directory.GetFiles(Server.MapPath("images")) files = Directory.GetFiles("C:\test")
'for display purposes, remove the path to the file
For index = 0 To files.Length - 1
files(index) = New FileInfo(files(index)).Name
Next index
'bind the list of files to the listbox on the form
lstFiles.DataSource = files
lstFiles.DataBind()
'select the first entry in the list
'NOTE: This is done to simplify the example since preselecting an
' item eliminates the need to verify an item was selected
lstFiles.SelectedIndex = 0
End If
End Sub
btnDownload_ServerClick
Dim file As FileInfo
Dim filename As String
'get the fully qualified name of the selected file
filename = "C:\test" & "\" & lstFiles.SelectedItem.Text()
'get the file data since the length is required for the download
file = New FileInfo(filename)
'write it to the browser
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & lstFiles.SelectedItem.Text)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(filename)
Response.End()
End Sub
and create folder in cdrive name as test and go to solution explorer create new folder add images names file.gif, up.gif, upload.gif then execute the code if you any dout please dont hesiteate send to me
|
| Author: banu 22 Oct 2008 | Member Level: Silver | Rating: Points: 5 |
if (upload.FileName != "") { objNewuserregprop.fileupload = upload.FileName; string img = Server.MapPath("~/fileupload/"); upload.PostedFile.SaveAs(img + upload.FileName); }
add file folder in your solution explorer..here my file folder is fileupload..if u upload any files in output then it will store in database and also in this folder..
if u got the answer tell me..
|