user738383
user738383

Reputation: 607

System.IO.Directory.GetFiles. No definition for GetFiles?

I wrote some code to get the files in a directory. In order to do this I used the Directory.GetFiles method. I've used it before, so I know it exists and works.

So I started using it (I'm using the System.IO namespace) and it tells me that 'System.IO.Directory' does not contain a definition for 'GetFiles'. Indeed, if I use the intellisense, there is no such method. MSDN tells me that there is though, and I know I've used it before, and I'm 99% sure it was System.IO.Directory.

I do have System.IO.Directory... it just doesn't have that method. It has methods like 'GetCreationTime', 'GetDirectoryRoot', 'GetLastAccessTime', 'SetCurrentDirectory' and so on, but no 'GetFiles'.

Can anyone offer any help?

Upvotes: 3

Views: 2829

Answers (2)

PeterPan
PeterPan

Reputation: 1

If you focus this issue using the framework of Silverlight 4 just change the use of .Getfiles(string directory) into .EnumerateFiles(string directory) instead

Upvotes: 0

Josh
Josh

Reputation: 44916

How are you making the call? That will tell us a lot about why the compiler might be complaining.

There are 3 Overloads for GetFiles on System.IO.Directory

Could you be looking for DirectoryInfo.GetFiles

Indeed, if I use the intellisense, there is no such method

The only 2 logical things I can think of that might cause this:

  1. Visual Studio, or your solution are in a corrupted state (Restart VS / Reboot)
  2. Your Project is targeting a version of .Net lower than 2.0 (GetFiles was introduced in 2.0)

Upvotes: 4

Related Questions