473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

display files in a directory on a .net web page

Hi just wondering a good way to display all files in a directory on a server
and have them selectable to be opened by the client machine. These files
change from time to time so would not want to hard code in the link and file
names as part of the hyperlink. Also would want to launch a new page so
would use the Target="_blank"
--
Paul G
Software engineer.
Jan 17 '06 #1
12 1668
I did this, and it worked well for us. I created an asp:Table and then
in the page load I programmatically added columns and rows...after
parsing a directory listing of the files. The end result is a nice
table with the file name, date modified, download link, etc. Also, it
is a good idea to store the files outside of the website and have the
app (ASPNET user) "go get" the file when the user clicks the download
link. I did this with a querystring and a separate (download) page.
That way, users cannot just type the file name and download.

Jan 17 '06 #2
In ASP.NET 2.0 the DirectoryInfo class can help you get a listing of your
files:
http://msdn2.microsoft.com/en-us/library/4cyf24ss.aspx

Then the TreeView control can help you display them with hyperlinks for
downloading them:
http://www.asp.net/QuickStart/aspnet.../treeview.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Paul" wrote:
Hi just wondering a good way to display all files in a directory on a server
and have them selectable to be opened by the client machine. These files
change from time to time so would not want to hard code in the link and file
names as part of the hyperlink. Also would want to launch a new page so
would use the Target="_blank"
--
Paul G
Software engineer.

Jan 17 '06 #3

Add a datalist, or datagrid in the page with a hyperlink inside

DirectoryInfo dire = new DirectoryInfo(sVirtualFolder);
FileInfo[] files = dire.GetFiles("*.*"); // mark of files

DataList.DataSource = files;
DataList.DataBind();

Happy programming
"Paul" wrote:
Hi just wondering a good way to display all files in a directory on a server
and have them selectable to be opened by the client machine. These files
change from time to time so would not want to hard code in the link and file
names as part of the hyperlink. Also would want to launch a new page so
would use the Target="_blank"
--
Paul G
Software engineer.

Jan 17 '06 #4
ok thanks for the information, not upgrading to 2.0 for awhile but nice to
know about its' features.
--
Paul G
Software engineer.
"Phillip Williams" wrote:
In ASP.NET 2.0 the DirectoryInfo class can help you get a listing of your
files:
http://msdn2.microsoft.com/en-us/library/4cyf24ss.aspx

Then the TreeView control can help you display them with hyperlinks for
downloading them:
http://www.asp.net/QuickStart/aspnet.../treeview.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Paul" wrote:
Hi just wondering a good way to display all files in a directory on a server
and have them selectable to be opened by the client machine. These files
change from time to time so would not want to hard code in the link and file
names as part of the hyperlink. Also would want to launch a new page so
would use the Target="_blank"
--
Paul G
Software engineer.

Jan 17 '06 #5
ok thanks I think this is what I was looking for.
--
Paul G
Software engineer.
"Albert Pascual" wrote:

Add a datalist, or datagrid in the page with a hyperlink inside

DirectoryInfo dire = new DirectoryInfo(sVirtualFolder);
FileInfo[] files = dire.GetFiles("*.*"); // mark of files

DataList.DataSource = files;
DataList.DataBind();

Happy programming
"Paul" wrote:
Hi just wondering a good way to display all files in a directory on a server
and have them selectable to be opened by the client machine. These files
change from time to time so would not want to hard code in the link and file
names as part of the hyperlink. Also would want to launch a new page so
would use the Target="_blank"
--
Paul G
Software engineer.

Jan 17 '06 #6
ok thanks may try this approach.
--
Paul G
Software engineer.
"Joey" wrote:
I did this, and it worked well for us. I created an asp:Table and then
in the page load I programmatically added columns and rows...after
parsing a directory listing of the files. The end result is a nice
table with the file name, date modified, download link, etc. Also, it
is a good idea to store the files outside of the website and have the
app (ASPNET user) "go get" the file when the user clicks the download
link. I did this with a querystring and a separate (download) page.
That way, users cannot just type the file name and download.

Jan 17 '06 #7
I used to do this, until we needed other information, like file name,
date modified, etc...

Jan 17 '06 #8
this seems to cause an error on the getfiles as it is on a different server.
The error is unkown user name or bad password loging in. I am able to get to
the server with windows explorer without a username and password, guess it
may be using domain information. Anyhow just if any ideas? Thanks.
--
Paul G
Software engineer.
"Joey" wrote:
I used to do this, until we needed other information, like file name,
date modified, etc...

Jan 17 '06 #9
The app will access the files as the ASPNET user, and it will not use
your account. Make sure the ASPNET account has the neccessary
permissions.

Jan 17 '06 #10
Or, if using IIS 6, its the NetworkService account.

Jan 17 '06 #11
I didn't know that. Thanks!

Jan 17 '06 #12
thanks, I do not know much about networks but wondering if I may need to add
the aspnet user to the domain or if there is a way I can have the .net
application use my windows authentication info.
--
Paul G
Software engineer.
"Joey" wrote:
I didn't know that. Thanks!

Jan 17 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stephen Harris | last post by:
I downloaded: Windows Binaries PHP 5.0.4 zip package - 31 Mar 2005 md5: fff10991a8e6f3b36ee567eb236ae3f4 This is the current BETA release of version 5.0 of the MySQL database server....
1
by: jajoo | last post by:
Hi everyone, I am trying to send files with multipart/form-date. Everything is ok with the send. But when I am receiving the files I should specify a directory where the files to be saved. The...
4
by: hoke | last post by:
I want to display plain text files in the browser. The files contain html and javascript and have a .txt extension. This works fine with files with just html. Unfortunately when showing files with...
7
by: TLM | last post by:
I am trying to build a web application that will contain links to files on a users local computer. I am assuming that the files will be in a known location and can display in a browser window. ...
5
by: Bas Hendriks | last post by:
Has anyone any idea how asp.net find it's files back after compiling them to the temporary asp.net directory? I found on numerous webpages that the directorynames are chosen random but cannot find...
4
by: Rush | last post by:
I'm new to web development in Visual Studio 2005, and I'm creating a web site using ASP.NET, and right now its a very simple page with only labels on it. I have a third party that hosts the site,...
5
by: David Thielen | last post by:
Hi; Ok, I will be the first to agree that this should be impossible - except we are able to keep repeating it. Our login page - which has moderately complex html and uses <LayoutTemplate> to...
9
by: kkhan5000 | last post by:
Hello, I am new to PHP and have put together the following code just by copying other examples from the web. Now I am stuck and would like to sort and display files alphabetically, and also filter...
23
by: shashi shekhar singh | last post by:
Dear sir, I have a word document file contains text and images, now i have saved it as a web page and wants to display it on browser , using , string str=directory.getfiles("");...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.