System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory



  • 1. Login controls - supported browsers
    Hi all, I'm looking at a few login control examples - LoginStatus, LoginView etc. - and they seem to rely heavily on Javascript. I cannot get them to work on early browsers, or when Javascript is disabled. Is there any way around this, short of creating my own browser-friendly controls? Are all of the ASP .NET controls that use postbacks pretty much useless without Javascript? Thanks, Paul
  • 2. Add iFrames dynamically
    Hello, I need to add iFrames dynamically to html. So, for each iFrame I need to set scr property with an image that will be printed without display the page. Is possible it? Thanks in advance. Gabriel.
  • 3. Gridview widths
    Is there any way to set the widths of gridview columns in VS Express. Simpler the better. Regards, Chris.
  • 4. Copy files from Novell with ASP.NET
    On a W2K3 box running IIS 6 I have a web app that implements Forms Authentication mixed with AD (the login page autheticates users against AD & impersonates them with each page request). This means my process identity varies, and is not necessarily "ASPNET" or "IUSR...". My process identity for any given page request will be user1, user2, user3, etc. (there's a lot of them) This web app needs to copy files (Word documents) from our old Novell 5 server onto the W2K3 box, and I'm encountering what I believe is a permissions problem. Here's what I've tried doing: IO.File.Exists(\\NovellServer\volume\folder\file.doc) This is a valid path to a valid file that does exist, but the query returns False. I assume the web app doesn't have access this server/volume/folder/file from within the security context of the currently executing request. Which does make sense since none of the users typically logging into the website ever needed or were ever granted logins to the Novell server. I do have one Novell login that is "synchronized" with AD (the username and password are the same). So, I attempted this: '...code gets to the point where it is ready to play with novell files: [impersonate as sychronized AD/Novell user] IO.File.Exists(\\NovellServer\volume\folder\file.doc) But this still returns False. I'm uncertain how to proceed. What else should I try?

System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory

Postby Nathan Sokalski » Sat, 08 Sep 2007 00:23:26 GMT

I have an ASP.NET application which displays the directories & files in a 
specified directory on the server. I use the 
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() to 
retrieve the lists of files and directories. I have two very similar 
versions of this that I am debugging, both of which use the methods 
mentioned above. However, one of them is returning the contents of the 
specified directory and the other is returning the contents of the project's 
directory. I have checked to see what values are used by and returned by 
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles(), and 
they use the values I expect, but do not return the directories and files in 
that directory. What is going on here? 

Re: System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory

Postby Mark Rae [MVP] » Sat, 08 Sep 2007 00:46:35 GMT

[X-posting removed]

Please show your code...

Mark Rae

Re: System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory

Postby zacks » Sat, 08 Sep 2007 00:58:52 GMT

Both of those methods work fine for me. You will need to post some
actual code that is having the problem.

Similar Threads:

1.System.IO.Directory / System.IO.FileInfo

2.System.IO.Directory.Delete Throws "the directory is not empty"

I am using VS2008 to create a website.  When I try to programmatically delete 
a directory that is located within my website I will get an error.  I am 
trying to delete the directory using "System.IO.Directory.Delete(strDirPath, 
true)".  This is the message the error gives "the directory is not empty".  I 
found another entry titled "Directory.Delete of a non empty dir fails in 
ASP.NET application".  In that posting Walter Wang says: "the folder is 
locked by Visual Studio 2005 IDE if the folder is already shown in project 
explorer".  Now that I am using VS2008 has this been changed?  How can I test 
my code?  Please help me get past this problem.

3.Current Directory (System.IO.Directory.GetCurrentDirectory throws NotSupportedexeption)


when i call System.IO.Directory.GetCurrentDirectory() i get a
Notsupportedexeption. What other possibilities are there to get to know the
Path to the main-executable?

Thanks in advance

4.Copying Directories System.IO.Directory class

Is there a way to copy directory contents using the System.IO.Directory class?
I want to make a full copy of one folder (files and subfolders) to another 
I'm able to move the folder using Directory.Move but that removes the files 
from the source folder.  I see File.Copy but that only copies an individual 
I don't see Directory.Copy so I'm not sure if this is easily accomplished.


5.Directory::GetDirectories returning non-existent directories

Assuming you have the default directory settings, try this code:

String^ full_path = "c:\\Users\\Owner\\Documents" ;
array<String^>^ dir_list = Directory::GetDirectories( full_path ) ;

In my case, it returns all the directories as it should in dir_list, but it 
also returns the following non-existent (hidden?) directories:

My Music
My Pictures
My Videos

If I try to Directory::GetFiles( ) on any of these directories it throws an 
exception, but it will successfully return the files of those directories 
which are visible or do exist.

If I do a 'search' for any directories with those names, they are not found.

I have a Windows Vista machine, and I'm programming in VS VC++ 2008 Express 
(Beta 2) /cli pure.

What is going on here? 

6. IO.Directory.GetFiles algorithm Bug?

7. (Newbie) IO.Directory.Getfiles()

8. System.IO.Directory.Delete - access denied exception

Return to ASP.NET


Who is online

Users browsing this forum: No registered users and 20 guest