Hello team,
I need to get some specific files from folder
Folder path like this -\10:20:10\track\survil file\comodity\MCx
Inside - \Mcx\current month folder (Dec2023)\day folder \ files
These are my file name for exin below image
Now we have to check files are available or not if files are not available den email to user if the file are available den move to destination path
I have done with for each file in folder it’s working but I have to create extra folder to move files and then I’m checking file available in that folder so this logic not looking good I need in one step check file available or not
Thanks
Anil_G
(Anil Gorthi)
December 3, 2023, 8:37am
2
@suraj_gaikwad
Use path exists to check the file or folder exists
Cheers
Yes, done that and it’s true
@Anil_G
Anil_G
(Anil Gorthi)
December 3, 2023, 8:53am
4
@suraj_gaikwad
So what is the issue now?
Cheers
Files are available but it’s going in else condition
@Anil_G
Anil_G
(Anil Gorthi)
December 3, 2023, 8:55am
6
@suraj_gaikwad
Did you try to log and check if it returned any files
Check the formula
Cheers
Anil_G
(Anil Gorthi)
December 3, 2023, 9:14am
8
@suraj_gaikwad
You are comparing locations there and i dont thing two locations are same
You need not have secon loop instead use this
Arrfiles.Any(function(x) Path.GetFileName(x).ToUpper.Contains(currentFile.Name.ToUpper))
Use this in if with out loop on arefiles …if file present it would go to then side
Cheers
Stil it’s going in else condition
@Anil_G
Anil_G
(Anil Gorthi)
December 3, 2023, 10:40am
10
@suraj_gaikwad
Can you please tell what is there in arrfiles check the value of it
Also can you log only name instead of fullname and check
I hope your array contains the filepaths and we are extracting only name which is same as currentfile name…please confirm the same
Better use two log messages one with currentfile.Name
and other with String.Join(",",arrfiles.Select(function(x) Path.GetFileName(x)))
This will show if names are matching or not at all
Cheers
In arrayfiles I provide file names
@Anil_G
Log messages output coming like this
@Anil_G
Anil_G
(Anil Gorthi)
December 3, 2023, 12:14pm
14
@suraj_gaikwad
Okay so you dont have extension
Change the formula like this
Arrfiles.Any(function(x) currentFile.Name.ToUpper.Contains(Path.GetFileName(x).ToUpper))
Cheers
Still it’s going else part
@Anil_G
Anil_G
(Anil Gorthi)
December 3, 2023, 1:46pm
16
@suraj_gaikwad
Add a trim and check…on both sides
Cheers
Anil_G
(Anil Gorthi)
December 3, 2023, 1:52pm
18
@suraj_gaikwad
Just to check do a replace of _ on both sides
Also log both of them separately
Cheers
Issue solve but I need directly go in true condition once the file match .
If the all files got den it’s in true condition otherwise in else condition
@Anil_G
Anil_G
(Anil Gorthi)
December 3, 2023, 3:30pm
20
@suraj_gaikwad
any works with atleast one match
or use where with .count>0
cheers