Tuesday, March 27, 2012

List of Files from URL Directory using VB

I am looking to get a list of files for a URL reference such as
http://localhost/manager/ for a certain search pattern say "*.xls". How do I
go about this using VB and what class libraries are best to use. If anyone
has any code or can redirect me to a better site then that would be great.
Thanks in advance.First you need to map the virtual path to the physical one. Do this with the
page's MapPath method.

Second, have a look into System.IO namespace. You will find plenty of
classes to operate on directories and files.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"MS" <ms@.ms.comwrote in message
news:eqlSyvIOHHA.3552@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>I am looking to get a list of files for a URL reference such as
>http://localhost/manager/ for a certain search pattern say "*.xls". How do
>I go about this using VB and what class libraries are best to use. If
>anyone has any code or can redirect me to a better site then that would be
>great.
Thanks in advance.
>
>


On Mon, 15 Jan 2007 10:06:31 -0000, MS wrote:

Quote:

Originally Posted by

I am looking to get a list of files for a URL reference such as
http://localhost/manager/ for a certain search pattern say "*.xls". How do I
go about this using VB and what class libraries are best to use. If anyone
has any code or can redirect me to a better site then that would be great.
Thanks in advance.


System.IO is your friend.

Once you have imported it you can do this:

'Get the physical path of the root
Dim folder As String = Page.MapPath("~")
'Get a string array of all excel files
Dim dirs As String() = Directory.GetFiles(folder, "*.xls")

--
Bits.Bytes
http://bytes.thinkersroom.com
Thanks all. I will try.

"Rad [Visual C# MVP]" <nospam@.nospam.comwrote in message
news:1gb608o91lz9x$.dlg@.thinkersroom.com...

Quote:

Originally Posted by

On Mon, 15 Jan 2007 10:06:31 -0000, MS wrote:
>

Quote:

Originally Posted by

>I am looking to get a list of files for a URL reference such as
>http://localhost/manager/ for a certain search pattern say "*.xls". How
>do I
>go about this using VB and what class libraries are best to use. If
>anyone
>has any code or can redirect me to a better site then that would be
>great.
>Thanks in advance.


>
System.IO is your friend.
>
Once you have imported it you can do this:
>
>
'Get the physical path of the root
Dim folder As String = Page.MapPath("~")
'Get a string array of all excel files
Dim dirs As String() = Directory.GetFiles(folder, "*.xls")
>
--
Bits.Bytes
http://bytes.thinkersroom.com

0 comments:

Post a Comment