Get Files in VB.Net

Advertisement

AvinashDesai
Joined:
Posts:
12
Location:
Bangalore - INDIA

Get Files in VB.Net

I have written code which connects and get the files from it .
I want to know how to retrieve only .txt files from that folder and that too latest one .

Reply with quote

Advertisement

AvinashDesai
Joined:
Posts:
12
Location:
Bangalore - INDIA

I want to know identifying the extension of the file and lastwrite time .. I used below code

InitFile = directory.Files.OrderByDescending(Function(f) f.LastWriteTime).First


To get the lastwrite time but it always returs name with "." I have txt files which I want mainly not all .. Is thr any property in the RemoteFileInfo which can help ?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Get Files in VB.Net

I do not know VB.NET, but in C# it would be like:

RemoteFileInfo latestTextFile = dir.Files.Where(file => file.Name.EndsWith(".cpp")).OrderByDescending(file => file.LastWriteTime).First();

Reply with quote

Advertisement

You can post new topics in this forum