directory listing

Hello,

I'd like my asp.net page to display a list of hyperlinks representing
the
files contained in a specific directory. The contents of this
directory
will change, but the directory does not contain any subfolders, only
pdf
files. The resulting list of hyperlinks should not allow a user to
'save
link as', to download the file, but rather only allow the user to view
the
file in their browser. What is the easiest way to get such a list on
my
page?

Thanks
Jesse.Aufiero [ Di, 15 April 2008 21:03 ] [ ID #1942646 ]

Re: directory listing

1. Create a directory /PDFs in your webfolder and mark it in IIS or you
deployment project as readable.
2. In your app list the directory using system.io.file / directory
namespaces
3. foreach directory read filename and path into a structure

an easy way is to create a dataset with a table (filename, date, etc...).
Adv. is you can bind that to a datagrid where you can use a link / template
column to show your link


--
Holger Kreissl
..NET Software Developer
http://kreissl.blogspot.com/



> Hello,
>
> I'd like my asp.net page to display a list of hyperlinks representing
> the
> files contained in a specific directory. The contents of this
> directory
> will change, but the directory does not contain any subfolders, only
> pdf
> files. The resulting list of hyperlinks should not allow a user to
> 'save
> link as', to download the file, but rather only allow the user to view
> the
> file in their browser. What is the easiest way to get such a list on
> my
> page?
>
> Thanks
Holger Kreissl [ Do, 17 April 2008 11:20 ] [ ID #1944334 ]

Re: directory listing

On Apr 15, 9:03=A0pm, Jesse.Aufi... [at] gmail.com wrote:
> Hello,
>
> I'd like my asp.net page to display a list of hyperlinks representing
> the
> files contained in a specific directory. =A0The contents of this
> directory
> will change, but the directory does not contain any subfolders, only
> pdf
> files. =A0The resulting list of hyperlinks should not allow a user to
> 'save
> link as', to download the file, but rather only allow the user to view
> the
> file in their browser. =A0What is the easiest way to get such a list on
> my
> page?
>
> Thanks

Example:

Dim dir As New IO.DirectoryInfo(Server.MapPath("/dir"))
Dim fis As IO.FileInfo() =3D dir.GetFiles()
Dim fi As IO.FileInfo

For Each fi In fis
Response.Write(fi.Name)
Next fi
lexa [ Mo, 21 April 2008 11:55 ] [ ID #1946576 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » directory listing

Vorheriges Thema: NameValueCollection
Nächstes Thema: FileUpload clears on Insert