4 Replies - 4607 Views - Last Post: 25 September 2007 - 07:06 AM Rate Topic: -----

#1 jp42  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 21-August 07

File download from server through asp.net page

Post icon  Posted 18 September 2007 - 06:08 AM

Hi all,

I need to create a file download functionality for work orders through an asp.net page...I would like the selection of files for download to be dynamic in that I am not hard coding the files available. I have seen some code around but a lot of what I have seen is older, was wondering if anyone had implemented this functionality lately and had any tips, code, suggestions etc? thanks in advance...
Is This A Good Question/Topic? 0
  • +

Replies To: File download from server through asp.net page

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: File download from server through asp.net page

Posted 18 September 2007 - 06:39 PM

If you want to list all the files in a certain directory, say your download directory, then make use of the following classes:

Then create a method like this:

Public Sub ListDownloadableFiles(ByVal dir As String)
		' make a reference to a directory
		Dim dirInfo As New IO.DirectoryInfo(dir)
		' Get all the files in the above directory
		Dim files As IO.FileInfo() = dirInfo.GetFiles()

		' Loop through all the files in the directory
		For Each file As IO.FileInfo In files
			'Add the files names to a ListBox
			 ListBox1.Items.Add(file)
		Next
End Sub



That's how you would display the files for download without hard coding any file names.

Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#3 jp42  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 21-August 07

Re: File download from server through asp.net page

Posted 19 September 2007 - 07:10 AM

View PostPsychoCoder, on 18 Sep, 2007 - 06:39 PM, said:

If you want to list all the files in a certain directory, say your download directory, then make use of the following classes:Then create a method like this:

Public Sub ListDownloadableFiles(ByVal dir As String)
		' make a reference to a directory
		Dim dirInfo As New IO.DirectoryInfo(dir)
		' Get all the files in the above directory
		Dim files As IO.FileInfo() = dirInfo.GetFiles()

		' Loop through all the files in the directory
		For Each file As IO.FileInfo In files
			'Add the files names to a ListBox
			 ListBox1.Items.Add(file)
		Next
End Sub


Thanks psycho, that is very helpful...hadnt done a directory listing in a while, thanks for reducing the intellectual overhead a bit...you caught right on to what i was trying to accomplish! - jp

This post has been edited by PsychoCoder: 19 September 2007 - 08:04 AM

Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: File download from server through asp.net page

Posted 19 September 2007 - 02:24 PM

No problem, thats what we're here for. Glad I could help :)
Was This Post Helpful? 0
  • +
  • -

#5 jp42  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 21-August 07

Re: File download from server through asp.net page

Posted 25 September 2007 - 07:06 AM

View PostPsychoCoder, on 19 Sep, 2007 - 02:24 PM, said:

No problem, thats what we're here for. Glad I could help :)



psycho, your code was helpful, worked like a charm...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1