directoryinfo

Filter DirectoryInfo files by date in asp.net

╄→尐↘猪︶ㄣ 提交于 2019-12-06 08:22:24
问题 I am populating a datagrid control using files in a specified path (DirectoryInfo). I would like to filter the files based on a user specified date range (start date & end date). While search S/O, I found this post, but I am getting an error on DateComparer ( "'DateComparer' is a type and cannot be used as an expression." ) Any other suggestions on how to filter by date? Here is my code: Dim dirInfo As New DirectoryInfo(strDirectoryPath) Dim dStartDate As DateTime = "03/01/2011" Dim dEndDate

DirectoryInfo.Delete(True) Doesn't Delete When Folder Structure is Open in Windows Explorer

只谈情不闲聊 提交于 2019-12-05 23:22:23
问题 Assuming I have a folder structure like: C:\MyTemp - MySubFolder If I try to delete this using: Dim path As String = "C:\MyTemp" Dim di As System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(path) di.CreateSubdirectory("MySubFolder") di.Delete(True) This works fine, unless I have Windows Explorer open and I'm looking at the 'MySubFolder' directory. Then I get an IOException The directory is not empty. - clicking OK dismisses this and then the folder structure is not deleted. Any

Sorting files from directoryinfo by date in asp.net

独自空忆成欢 提交于 2019-12-05 11:52:38
how can I sort (not filter) directoryinfo files by date (oldest to recent) ? I am using asp.net and visual studio 2008 apros The same as @DaRKoN_ in vb.net: Module Module1 Sub Main() Dim orderedFiles = New System.IO.DirectoryInfo("c:\\").GetFiles().OrderBy(Function(x) x.CreationTime) For Each f As System.IO.FileInfo In orderedFiles Console.WriteLine(String.Format("{0,-15} {1,12}", f.Name, f.CreationTime.ToString)) Next End Sub End Module The GetFiles() method on the DirectoryInfo class returns an Array, which implements IEnumerable. So you can apply all the standard LINQ extension methods. var

Pass an IO.DirectoryInfo property as a parameter to a function?

故事扮演 提交于 2019-12-04 19:37:38
This function uses the bubble algorithm to sort a list of IO.DirectoryInfo by their Name property. How I can specify in a parameter the property that I will to sort the list? For example: "Drive", "Name", "Name.Length", "Directory.Parent", etc... What I thought like a good idea (maybe is not good, I don't know how much can be improved this) is to pass the parameter as string and then cast the string as...? Here is where I'm lost. Public Shared Function BubbleSort_List(list As List(Of IO.DirectoryInfo), ByVal SortByProperty As ...) As List(Of IO.DirectoryInfo) Return list.Select(Function(s) New

Filter DirectoryInfo files by date in asp.net

ぃ、小莉子 提交于 2019-12-04 14:20:08
I am populating a datagrid control using files in a specified path (DirectoryInfo). I would like to filter the files based on a user specified date range (start date & end date). While search S/O, I found this post, but I am getting an error on DateComparer ( "'DateComparer' is a type and cannot be used as an expression." ) Any other suggestions on how to filter by date? Here is my code: Dim dirInfo As New DirectoryInfo(strDirectoryPath) Dim dStartDate As DateTime = "03/01/2011" Dim dEndDate As DateTime = "6/30/2011" Dim Files As FileInfo = dirInfo.GetFiles().Where(Function(Files) Files

Why isn't this DirectoryInfo comparison working? [duplicate]

不想你离开。 提交于 2019-12-04 05:14:27
This question already has answers here : Closed 7 years ago . Possible Duplicate: How to check whether 2 DirectoryInfo objects are pointing to the same directory? var dirUserSelected = new DirectoryInfo(Path.GetDirectoryName("SOME PATH")); var dirWorkingFolder = new DirectoryInfo(Path.GetDirectoryName("SAME PATH AS ABOVE")); if (dirUserSelected == dirWorkingFolder) { //this is skipped } if (dirUserSelected.Equals(dirWorkingFolder)) { //this is skipped } Whilst debugging, I can examine the values in each and they ARE equal. So i'm guessing this is another byval byref misunderstanding... Please

DirectoryInfo.Delete(True) Doesn't Delete When Folder Structure is Open in Windows Explorer

做~自己de王妃 提交于 2019-12-04 05:13:45
Assuming I have a folder structure like: C:\MyTemp - MySubFolder If I try to delete this using: Dim path As String = "C:\MyTemp" Dim di As System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(path) di.CreateSubdirectory("MySubFolder") di.Delete(True) This works fine, unless I have Windows Explorer open and I'm looking at the 'MySubFolder' directory. Then I get an IOException The directory is not empty. - clicking OK dismisses this and then the folder structure is not deleted. Any thoughts on how I can get this to perform correctly (i.e. delete), even when running this code while

Show progress when searching all files in a directory

 ̄綄美尐妖づ 提交于 2019-12-03 09:59:36
问题 I previously asked the question Get all files and directories in specific path fast in order to find files as fastest as possible. I am using that solution in order to find the file names that match a regular expression. I was hoping to show a progress bar because with some really large and slow hard drives it still takes about 1 minute to execute. That solution I posted on the other link does not enable me to know how many more files are missing to be traversed in order for me to show a

Show progress when searching all files in a directory

青春壹個敷衍的年華 提交于 2019-12-03 00:34:11
I previously asked the question Get all files and directories in specific path fast in order to find files as fastest as possible. I am using that solution in order to find the file names that match a regular expression. I was hoping to show a progress bar because with some really large and slow hard drives it still takes about 1 minute to execute. That solution I posted on the other link does not enable me to know how many more files are missing to be traversed in order for me to show a progress bar. One solution that I was thinking about doing was trying to obtain the size of the directory

Show files from 2 different folders in a single Gridview

◇◆丶佛笑我妖孽 提交于 2019-12-02 13:31:25
Is it possible to show files from 2 different folders (c:\test1 and c:\test2) in the same gridview? I work in VB.net (VS 2010) Thanks! Yes. Get list of all the files using Directory.GetFiles() into a single IEnumerable<string> and bind it to a GridView. This is how you'll do it in c#. List<string> allFiles = new List<string>(); allFiles.AddRange(Directory.GetFiles(@"C:\test1\*")); allFiles.AddRange(Directory.GetFiles(@"C:\test2\*")); yourGV.DataSource = allFiles; yourGV.DataBind(); Try something like this: Dim files As New List(Of String)() files.AddRange(GetAllFilesFromDir("C:\foo")) files