Files

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
I have a current directory and i want to retrive files drom Date A till
Date B. How can I do it in c#?
Thank you!
 
csharpula csharp said:
I have a current directory and i want to retrive files drom Date A till
Date B. How can I do it in c#?

Use DirectoryInfo.GetFileSystemInfos, then use whichever property you
want (eg CreationTime, LastAccessTime etc) of each FileSystemInfo
returned to work out whether or not you're interested in it.
 
Hi,

csharpula said:
Hello,
I have a current directory and i want to retrive files drom Date A till
Date B. How can I do it in c#?
Thank you!

I don't think there is a built-in function for that. But it's easy
enough to do: Get all the files in the directory using
DirectoryInfo.GetFiles
http://msdn2.microsoft.com/en-us/library/system.io.directoryinfo.getfiles.aspx

Then loop through the found files, and check the dates using
FileInfo.CreationTime or FileInfo.LastWriteTime or
FileInfo.LastAccessTime (depending which you want)
http://msdn2.microsoft.com/en-us/library/system.io.fileinfo_members.aspx

HTH,
Laurent
 
Hello,
All I can get from DirectoryInfo is DirectoryInfo.Equals and there is no
GetFiles.How to solve it?
(I can use Directory.GetFiles() but then I get strings(files names) and
not files eneries.
Thank you
 
Hello,
All I can get from DirectoryInfo is DirectoryInfo.Equals and there is no
GetFiles.How to solve it?
(I can use Directory.GetFiles() but then I get strings(files names) and
not files eneries.
Thank you
 
Hi,

GetFiles is an instance method, not a static method.

If you're using Visual Studio you can open the Object Browser, then enter
GetFiles into the search box. Find the method in the list of results,
select it, and look at the description pane below (notice that the "static"
keyword isn't present on any of the DirectoryInfo.GetFiles method
overloads).
 
Hi,

csharpula said:
Hello,
All I can get from DirectoryInfo is DirectoryInfo.Equals and there is no
GetFiles.How to solve it?
(I can use Directory.GetFiles() but then I get strings(files names) and
not files eneries.
Thank you

When I said "DirectoryInfo.GetFiles", I just meant the method GetFiles
of the DirectoryInfo class, which happens to be an instance method and
not a static method (as you would have seen if you had followed the link
provided). I agree that my notation was not the best.

First you create a new DirectoryInfo instance.
Then you use the GetFiles method.
And then you loop through them and check the dates.

HTH,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top