473,797 Members | 3,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting List of Files in a Folder

I am not sure if this is even possible, but I figured I'd ask some experts.
How would I use an ASP.NET page to get a listing of all of the files that
are in a folder. I am working on a page that can show a group of users if
their reports are in a folder (kind of like a report distribution page). If
that is possible then how could I put a link on the page to that file so the
user could open it.

Thanks!

--
Chuck Foster
Programmer Analyst
Eclipsys Corporation - St. Vincent Health System
Nov 19 '05 #1
7 19246
DirList.aspx
=========
<script language="vb" runat="server">
Sub Page_Load()
Dim StoreFile As System.IO.Direc tory
Dim Files As String()
Dim File As String
Files = StoreFile.GetFi les("drive:\dir ectory\path\", "*")
For Each File In Files
Response.Write( File & "<br>")
Next
End Sub
</script>

<html>
<head><title>Fi le List</title></head>
<body>

</body>
</html>
---------

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=============== ======

"chuckdfost er" <ch**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I am not sure if this is even possible, but I figured I'd ask some experts.
How would I use an ASP.NET page to get a listing of all of the files that
are in a folder. I am working on a page that can show a group of users if
their reports are in a folder (kind of like a report distribution page).
If
that is possible then how could I put a link on the page to that file so
the
user could open it.

Thanks!

--
Chuck Foster
Programmer Analyst
Eclipsys Corporation - St. Vincent Health System

Nov 19 '05 #2
"chuckdfost er" <ch**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I am not sure if this is even possible, but I figured I'd ask some experts.
How would I use an ASP.NET page to get a listing of all of the files that
are in a folder. I am working on a page that can show a group of users if
their reports are in a folder (kind of like a report distribution page).
If
that is possible then how could I put a link on the page to that file so
the
user could open it.


No problem at all. Take a look at the System.IO namespace, instantiate a
Directory object and then call its GetFiles method e.g.

using System.IO;

string[] astrFiles = Directory.GetFi les(<directory name goes here>, "*.*");
foreach (string strFile in astrFiles)
{
// write out a hyperlink to the file which the users can click
}

Make sure that the account that ASP.NET is running under needs to be able to
"see" the directory and have sufficient permissions on it to get a listing
of its files.
Nov 19 '05 #3
Chuck:

check out System.IO.Direc tory.GetDirecto ries and
System.IO.Direc tory.GetFiles

for each file as string in System.IO.Direc tory.GetFiles(" c:\repository\" )

next

If there's a folder tree (ie, you need to recurse), you'll need a recursive
function. How to put a link to the file depends on whether the file exists
in the web directory or in some other folder. If it's in the web
directory, you can simply link to it. Otherwise look at the
REsponse.WriteF ile method.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"chuckdfost er" <ch**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I am not sure if this is even possible, but I figured I'd ask some experts. How would I use an ASP.NET page to get a listing of all of the files that
are in a folder. I am working on a page that can show a group of users if
their reports are in a folder (kind of like a report distribution page). If that is possible then how could I put a link on the page to that file so the user could open it.

Thanks!

--
Chuck Foster
Programmer Analyst
Eclipsys Corporation - St. Vincent Health System

Nov 19 '05 #4
Juan:
Your use of a shared field like that struck me odd. System.IO.Direc tory
can't be created (constructor is private, class is sealed and all members
are static) so, in my opinion you should always use System.IO.Direc tory.XXX
instead of creating a field and then doing someField.XXX. In VB.Net you can
do:

Dim x as System.IO.Direc tory

but in C# you can't do the same, ie:

System.IO.Direc tory x = System.IO.Direc tory;

Might just be a personal preference of mine, all I could quickly dig up was
this discussion:
http://dotnetjunkies.com/WebLog/gran...3/02/8249.aspx
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:u8******** ******@TK2MSFTN GP15.phx.gbl...
DirList.aspx
=========
<script language="vb" runat="server">
Sub Page_Load()
Dim StoreFile As System.IO.Direc tory
Dim Files As String()
Dim File As String
Files = StoreFile.GetFi les("drive:\dir ectory\path\", "*")
For Each File In Files
Response.Write( File & "<br>")
Next
End Sub
</script>

<html>
<head><title>Fi le List</title></head>
<body>

</body>
</html>
---------

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=============== ======

"chuckdfost er" <ch**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I am not sure if this is even possible, but I figured I'd ask some experts. How would I use an ASP.NET page to get a listing of all of the files that are in a folder. I am working on a page that can show a group of users if their reports are in a folder (kind of like a report distribution page).
If
that is possible then how could I put a link on the page to that file so
the
user could open it.

Thanks!

--
Chuck Foster
Programmer Analyst
Eclipsys Corporation - St. Vincent Health System


Nov 19 '05 #5
Looks like we found something which can be
done in VB.NET which can't be done in C#.

;-)

No errors, no warnings. It just works.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=============== ======

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:eG******** ******@TK2MSFTN GP10.phx.gbl...
Juan:
Your use of a shared field like that struck me odd. System.IO.Direc tory
can't be created (constructor is private, class is sealed and all members
are static) so, in my opinion you should always use
System.IO.Direc tory.XXX
instead of creating a field and then doing someField.XXX. In VB.Net you
can
do:

Dim x as System.IO.Direc tory

but in C# you can't do the same, ie:

System.IO.Direc tory x = System.IO.Direc tory;

Might just be a personal preference of mine, all I could quickly dig up
was
this discussion:
http://dotnetjunkies.com/WebLog/gran...3/02/8249.aspx
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:u8******** ******@TK2MSFTN GP15.phx.gbl...
DirList.aspx
=========
<script language="vb" runat="server">
Sub Page_Load()
Dim StoreFile As System.IO.Direc tory
Dim Files As String()
Dim File As String
Files = StoreFile.GetFi les("drive:\dir ectory\path\", "*")
For Each File In Files
Response.Write( File & "<br>")
Next
End Sub
</script>

<html>
<head><title>Fi le List</title></head>
<body>

</body>
</html>
---------

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=============== ======

"chuckdfost er" <ch**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
>I am not sure if this is even possible, but I figured I'd ask some experts. > How would I use an ASP.NET page to get a listing of all of the files that > are in a folder. I am working on a page that can show a group of users if > their reports are in a folder (kind of like a report distribution
> page).
> If
> that is possible then how could I put a link on the page to that file
> so
> the
> user could open it.
>
> Thanks!
>
> --
> Chuck Foster
> Programmer Analyst
> Eclipsys Corporation - St. Vincent Health System
>
>



Nov 19 '05 #6
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Looks like we found something which can be
done in VB.NET which can't be done in C#.

;-)

No errors, no warnings. It just works.


Wow!
Nov 19 '05 #7
Thanks to everyone! This is all great help.
Chuck
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uD******** ******@TK2MSFTN GP12.phx.gbl...
Chuck:

check out System.IO.Direc tory.GetDirecto ries and
System.IO.Direc tory.GetFiles

for each file as string in System.IO.Direc tory.GetFiles(" c:\repository\" )

next

If there's a folder tree (ie, you need to recurse), you'll need a recursive function. How to put a link to the file depends on whether the file exists in the web directory or in some other folder. If it's in the web
directory, you can simply link to it. Otherwise look at the
REsponse.WriteF ile method.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"chuckdfost er" <ch**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I am not sure if this is even possible, but I figured I'd ask some

experts.
How would I use an ASP.NET page to get a listing of all of the files that are in a folder. I am working on a page that can show a group of users if their reports are in a folder (kind of like a report distribution page).

If
that is possible then how could I put a link on the page to that file so

the
user could open it.

Thanks!

--
Chuck Foster
Programmer Analyst
Eclipsys Corporation - St. Vincent Health System


Nov 19 '05 #8

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

Similar topics

1
11399
by: RFS | last post by:
how do I get the path to the Program Files folder?
3
3908
by: Rajiv Das | last post by:
VS 2003, XP SP2 ------------------------------------------------------------ DirectoryInfo temporary = new DirectoryInfo( Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)); FileInfo files = temporary.GetFiles(); foreach(FileInfo fi in files) { Console.WriteLine(fi.FullName); }
5
4471
by: Roy | last post by:
My dll file is copied to the "%windir%\Microsoft.NET\Framework\{version}Temporary ASP.NET Files" folder when I compile my asp.net project. When I run the application. The dll under this folder is loaded, not the one under bin folder. Why is that? How can I load the one under bin folder?
1
2574
by: mmohanra | last post by:
I am trying to list files in a folder in a remote server. I am using Scripting.FileSystemObject. This seems to be really slow. After a long time the connection times out. Is there any other way to list files in a folder? Below is the current code: Dim fs, f, fc Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(Whichfolder) Set fc = f.files We were using Scripting.FileSystemObject for uploading files to...
0
1155
by: studentintau | last post by:
I would thank you if you help me with the next subject : how do i copy all files from temporary internet files folder to another folder in drive D?
3
2627
by: froditus | last post by:
Hello everyone, is it possible to list files from directory other than in apache web directory? my web folder is placed on c:/ and i put my files in windows directory "d:/files/images/". I want those files to be able to view in client browser. when i tested using server computer it succeed. but from client computer i got nothing. I checked the html sources and the files is directly loaded from "d:/
5
1733
by: Warren Tang | last post by:
Hi I am trying to debug the code generated for aspx files. The following assembly is generated for an aspx page: App_Web_webform1.aspx.19c0ab3f.kajnxlqq.dll!ASP.main_test_webform1_aspx.ProcessRequest(System.We... However when I click on the it in the Call Stack window, it says: There is no source code available for the current location.
20
47784
by: Netwatcher | last post by:
Hello, I've been trying to get a list of files from given directory in C++ (with win32) but i encountered some weird problems //test snippet #include <windows.h> #include <stdio.h> #include <iostream> int main()
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10469
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10209
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7560
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.