开发者

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

开发者 https://www.devze.com 2023-04-10 14:14 出处:网络
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.

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 defini开发者_Go百科tion 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?


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)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号