2

These are the codes that I have tried

Dim myDirectory As new.IO.DirectoryInfo("C:\MyFolder") 

Dim myFiles() As String = myDirectory.GetFiles.OrderByDescending(Function(x) x.LastWriteTime).Select(Function(x) x.FullName).Take(40).ToArray

MsgBox(String.Join(Environment.NewLine, myFiles)

Here since I am giving Take(40), it will be taking only last 40files, but I want which can take all files which are modifies in last 24hrs(it may be 100 or 1000)

user692942
  • 16,398
  • 7
  • 76
  • 175
mouny
  • 45
  • 1
  • 7
  • Doesn't look like VBScript more like VB.Net judging by the Linq syntax. – user692942 Oct 11 '21 at 18:26
  • yes its vb.net, In UiPath we can use vb.net or c# for invoke code activity – mouny Oct 11 '21 at 18:45
  • Remove the Take(40), that will return you all files, then Function(x) x.LastWriteTime >= Date.Now.AddDays(-1). – Hursey Oct 11 '21 at 20:26
  • Dim myDirectory As new.IO.DirectoryInfo("C:\MyFolder") Dim myFiles() As String = myDirectory.GetFiles.OrderByDescending(Function(x) x.LastWriteTime>= Date.Now.AddDays(-1)).Select(Function(x) x.FullName).ToArray MsgBox(String.Join(Environment.NewLine, myFiles) - @Hursey I tried the way u told, I am getting all the files present in that folder not the files which are created/modified in 24hrs, I want files only which are created/updated in last 24hrs – mouny Oct 11 '21 at 20:44
  • Can you please tell me how to move those current files from one folder to other folder, I used copy folder of studiox activity , but it is taking whole folder not only the last 24hrs created/modified files. – mouny Oct 19 '21 at 21:21

1 Answers1

1

If you want to find all the files that were modified in the last 24 hours you can use a StudioX activity to loop through each file and then use the LastModifiedDate method to find the data they were modified.

First, you will need to click Show StudioX activities in the Activities window filter.

enter image description here

Then, select the For Each File in Folder activity.

enter image description here

After that, use this formula in the If activity: Convert.ToDateTime(CurrentFile.LastModifiedDate()) > Now.AddDays(-1)

enter image description here

In this example, the name of any file that was modified in the last 24 hours will show up in a message box.

Scott Ridings
  • 744
  • 1
  • 8
  • 14
  • Sure thing, be sure to look through more of those StudioX activities. I think you'll find more things to help you in your projects. – Scott Ridings Oct 12 '21 at 14:18
  • yeah sure I am new to Uipath, I'll definitely explore – mouny Oct 12 '21 at 17:23
  • Can you please tell me how to move those current files from one folder to other folder, I used copy folder of studiox activity , but it is taking whole folder not only the last 24hrs created/modified files. – mouny Oct 19 '21 at 19:45
  • You can replace the Message Box activity in my example with the Move File activity from StudioX. – Scott Ridings Oct 20 '21 at 01:32
  • I cannot find move file activity in studiox, I have move folder activity and when I used that it is taking all the files in the folder but not the latest/modified CurrentFile . And my requirement is to copy CurrentFiles from one folder to another. – mouny Oct 20 '21 at 11:54
  • Try updating your packages. On the Design tab, you should see the Manage Packages button. After updating, search for the Move File activity. – Scott Ridings Oct 20 '21 at 12:57
  • Can you please look into "How to copy multiple files which are created or modified in last 24hrs from one folder to another folder in UI Path?" this question, I have attached the screenshots as well – mouny Oct 20 '21 at 19:17