Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • Wouldn't you have to supply the full path to the lambda to get the Where clause to work? Just curious? :) Commented May 26, 2010 at 11:38
  • Note: You don't need a separate call to Where - FirstOrDefault can accept a predicate. Commented May 26, 2010 at 11:40
  • True, @Mark Byers, and I don't think the above code does what is required or am I missunderstanding something? Directory.GetFiles() returns a string containing the full paths as the file names, so you would need to take that into account in the predicate as well. Commented May 26, 2010 at 11:45
  • @Mark: GetFiles return string[]. Commented May 26, 2010 at 11:57
  • Yes daft you rite.its return the full path of .I just need the first file name.Could you pls guide me how can i get the only first file name? Commented May 26, 2010 at 11:57