Thanks for the responses...
This is what I got using a DropDownList and a Button.
Dim parentfolder As String = "recipes"
Dim myDir As New DirectoryInfo(S erver.MapPath(p arentfolder))
Me.DDLFileNames .DataSource = myDir.GetFiles( "*.doc")
Me.DDLFileNames .DataBind()
Session("FilePa th") = myDir.ToString
**Click the download button and...
Session("FileNa me") = Me.DDLFileNames .SelectedItem.T oString
Response.Redire ct("FileDownloa d.aspx")
**page load in FileDownload.as px
Dim filename As String = DirectCast(Sess ion("FileName") , String)
Dim filepath As String = DirectCast(Sess ion("FilePath") , String)
Dim fullpath As String = filepath + "\" + filename
Response.Clear( )
Response.Conten tType = "applicatio n/octet-stream"
Response.AddHea der("Content-Disposition", _
"attachment ; filename=""" & filename & """")
Response.Flush( )
Response.WriteF ile(fullpath)
Session.Abandon ()
This works great running at home but when I upload it to my server the
file(aword.doc) gets downloaded and it is empty. Any ideas why that is?
Thanks again.
"Laurent Bugnion" <ga*********@bl uewin.chwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi,
Shahzad Godil wrote:
>You can use FileSystemObjec t like this.
<%
Set objFSO=Server.C reateObject("Sc ripting.filesys temobject")
Set objFold=objFSO. GetFolder("E:\a dmin\uploads")
Set objfiles=objFol d.files
%>
and then generating my drop down using
<select name="productTh umb" id="productThum b">
<option><%Fo r Each objFile in objFolder.files
objFile.Name
Next
%></optio
Shahzad Godil
Karachi-Pakistan.
Are you seriously proposing using the FileSystemObjec t in an ASP.NET
environment? That's sub-optimal to say the least
To the OP: You get a list of files in a folder using the
System.IO.Direc toryInfo class.
For example:
DirectoryInfo dir = new DirectoryInfo( "c:\\temp" );
if ( dir.Exists )
{
FileInfo[] filesInDir = dir.GetFiles();
}
http://msdn2.microsoft.com/en-us/lib...ctoryinfo.aspx
HTH,
Laurent
>>
"ma********@ya hoo.com" <Ma********@yah oo.comwrote in message
news:ev******* **********@news svr27.news.prod igy.net...
>>I'm using .net 1.1 trying to get a list of files in folder on the
server. The user would select the file they want to download from a
DropDownLis t. Can someone tell me how this should be done? I can't find
the right class or object to use. Is it the File class or the
FolderBrowser ? Stuck like Chuck!!! Any suggestions welcome. Thanks.
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch