473,320 Members | 1,946 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,320 software developers and data experts.

Problem with GetFiles

when i run the code below to search my entire c drive.. i get this following
error message:

Access to the path "c:\System Volume Information" is denied.
Line 29: foreach (string f in Directory.GetFiles(d, ".mp3"))
In web.config i have <identity impersonate="true"/>

When i run the same code in Windows Form it works fine, also i like to know
how i can put the results into an array instead of using response.write.

public class Search : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
DirSearch("c:\\");
}

public void DirSearch(string sDir){

foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, ".mp3"))
{
Response.Write(f);
}
DirSearch(d);
}
}
Nov 18 '05 #1
1 1208
Windows Forms and other executables run under the System account. ASP.Net
runs under a different account, by default either ASPNET or Network Service,
with restricted privileges, for security reasons. You just need to grant
the necessary file IO permission to the account on your system under which
the ASP.Net worker process runs.
also i like to know
how i can put the results into an array instead of using response.write.
(Watch your bedside mannner, here, Kevin) Ummm. Directory.GetFiles() RETURNS
an array. And BTW, using Response.Write is really klugy with ASP.Net, which
is object-oriented.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"huzz" <hu**@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com... when i run the code below to search my entire c drive.. i get this following error message:

Access to the path "c:\System Volume Information" is denied.
Line 29: foreach (string f in Directory.GetFiles(d, ".mp3"))
In web.config i have <identity impersonate="true"/>

When i run the same code in Windows Form it works fine, also i like to know how i can put the results into an array instead of using response.write.

public class Search : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
DirSearch("c:\\");
}

public void DirSearch(string sDir){

foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, ".mp3")) {
Response.Write(f);
}
DirSearch(d);
}
}

Nov 18 '05 #2

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

Similar topics

4
by: FS | last post by:
hi guys i wanna list the files of a user-chosen directory using getfiles(path)... path is in this case SearchFilesDialog.SelectedPath.ToString()... but that causes an exception tellin me that...
1
by: Antonio | last post by:
Good morning, I've the following file system : C: -> HTML -> Aziende -> Azienda_1 -> a.jpg -> Azienda_2 -> a.jpg ... -> Azienda_N -> a.jpg my desire is to create an array of fileinfo...
3
by: xenophon | last post by:
This following innocuous code: System.IO.DirectoryInfo fff = new System.IO.DirectoryInfo(); System.IO.FileInfo ppp = fff.GetFiles( Request.MapPath(".") ); for( int ccc=0 ; ccc < ppp.Length ;...
11
by: al jones | last post by:
I'm using filesystem.getfiles - and so far it's working correctly *however* I'd sure like to be able to pass it, as the last parameter, the extensions (plural) for which I'm looking. I assumed...
1
by: Hawk | last post by:
I was writing my own wildcard compare algorithm and making a custom GetFiles routine when I came across what I think is a bug in .net's own GetFiles. My routine was coming up with different...
1
by: jobs | last post by:
Say I only have a single file I want to get information on. How can I adapt this code? Dim dr As DataRow Dim fi As FileInfo Dim dir As New DirectoryInfo(filename) Dim dt As New DataTable...
9
by: Julie Smith | last post by:
Hi, Is it just me or does the search pattern parameter in Directory.GetFiles() have a problem with the '?' character? '*.*' works to find all files, but '?.*' does not work to find all files...
3
by: Michael Jackson | last post by:
In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path) to get all the files in the directory. However, I'm getting an error regarding "Illegal character in Path", even though I...
3
by: coolestavi007 | last post by:
Hi All, I am facing a problem in Ziping any file and then sending it to another server through FTP. What I have to actually do is to retrive the property of files of any directory and then find...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.