How to get multiple files from yesterday date folder?

Hello team,

How do I get multiple files yesterday date from main yesterday day folder\subfolder

Like

Ex :-

\12.32.3\Edel_cap\Rc\Commoditi\MCX 23-24\DEC 23\MCX1012\ now files

But my issue is if the Jan 1 come and i have to get yesterday date file From DEC 23 how can I get bcz folder name will change accordingly date and month
And year

Thanks

Hi @suraj_gaikwad

Try this:

Assign (String)
yesterday = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")

Assign (Array of String)
files = Directory.GetFiles(myDirectory, "*" & yesterday & "*")

If
files.Length = 1

Assign (String)
result = files(0)
Else

Throw
New BusinessRuleException("How dare you?")

Hope it helps

Till folder path is fixed :point_up_2:

Next folder with current year and next year :point_up_2:

Inside that this folder current month and current year of last two digit :point_up_2:

This final folder and inside thi files are there :point_up_2:

I have done

Till inside full path by using multiple assign that assigned where all folder name I have saved that merge in full path so where I have to use this condition

@Parvathy

Thanks

@suraj_gaikwad

You can build the same above pth using

Now.AddDays(-1).ToString("MMM yy") + "\MCX" + Now.AddDays(-1).ToString("ddMM") your files are here

Cheers

Hi @suraj_gaikwad ,
You can get base on datatime.now.addDay(-1).toString
regards,

If for example

Today Is date 1 Jan 2024 and i have to get yesterday file means

Dec 31 so it will work

@Anil_G
@Parvathy @Nguyen_Van_Luong1

Thanks

@suraj_gaikwad

Yes now.adddays(-1) will get the previous day even if it is a different year and all

So yes it works for jan 1st

Cheers

Ok ! No need of if condition to check

And how I can add MCX 23-24 before month folder bcz I have used mod 100 for the last digit of both year current and next

@Anil_G

@suraj_gaikwad

.ToString(“yy”) will givw the year

You can use "MCX " + Now.AddYears(-1). ToString("yy") + "-" + Now.ToString("yy")

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.