Search a CSV file in a particular folder

I have a CSV file at particular location.
i want to first check if the file exist and then if the file is present then read that file.
The Problem is the file name is dyanamic but there this a fixed name pattern at the starting part as below

ALL.CMR911 Easysuit Migration_ is the fixed starting part of the filename.
So please anyone can help out to solve this issue.

If we need to file.exists then we need to get exact file name …so can you tell me what comes afterwards at the end of file ?

cant we search the files in the folder that starts with the above filename format, because the end part is dynamic

@vishal_nachankar - Yes you can search and if there is multiple files then it will return the result in string.array…will that be ok?

is it is totally fine if that folder has multiple files as once i read the file i will move that file to the achieve folder

@vishal_nachankar - here you go…

StrArrFiles = Directory.GetFiles(YourPath," *ALL.CMR911 Easysuit Migration_ *)

Remove the space before the * …added just to show that…

@prasath17 gave the right statement but the editor was interpretating it as fomat assignments

his answer formatted with the </> button:
StrArrFiles = Directory.GetFiles(YourPath," *ALL.CMR911 Easysuit Migration_* )

1 Like

I think the right one:

     StrArrFiles = Directory.GetFiles(YourPath,"*ALL.CMR911 Easysuit Migration_*.csv" )

Because your were looking for csv :wink:

And to check if there is result:

If with condition StrArrFiles.Count > 0

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