Dim files = From file In My.Computer.FileSystem.GetFiles("E:\docs") Order By file Select file
The variable 'files' would contain IEnumerable of String objects. The compiler automatically gets to know the type of result the query would return. And the variable is automatically type-casted according to returned result, thus variable would be having all the file names from the directory. Once we have the file names, we would now display file information on DataGridView as a list.
For this we will again use FileSystem to get the file information. With GetFileInfo of FileSystem we get all the attributes related to a file, like name, creation time, size etc. If we were not to use LINQ here, it would have required getting a Collection of FileInfo objects and then using loop we would have retrieved values to store into an array. With query-based coding, a developer can use LINQ to traverse and retrieve objects.
Get most out of your technology infrastructure investments with Dell
About CIOL | Media Kit | Site Map | Contact Us | Help | Write to us | Jobs@CyberMedia | Privacy Policy
Copyright © CyberMedia India Online Ltd. All rights reserved. Usage of content from web site is subject to Terms and Conditions.