Read excel from a path dynamically

Hi,

How to read the excel files present in a path dynamically (without specifying the file name)?

Hi @Aishwarya
You can Read all files exists into a directory by using Directory.GetFiles(FOLDER_PATH+"\INPUT",".",SearchOption.AllDirectories)

Then inside for each you can make a condition to read-only excel files like this :slight_smile:

Path.GetExtension(item)=".xlsx"

Just a quick sample for you:
Exceldynamic.zip (2.0 KB)

String[ ] return_Value = Directory.GetFiles(“D:\Test”,"*.xlsx") // This will return you only the *.xlsx files from a particular folder path only.

Directory.GetFiles("","")

path
Type: System.String

The relative or absolute path to the directory to search. This string is not case-sensitive.

searchPattern
Type: System.String

The search string to match against the names of files in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.

Return Value
Type: System.String

An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found.

1 Like

Thank you. It worked :slight_smile:

1 Like

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