How to get the name of a specific excel file

Hi guys,

How to get the only the name of a specific excel file.

Ex: this is my excel path. C:\users\training\documents\excel1.xlsx

Here I need to get only the name as “excel1” So that I can added this name to a new excel that is generated.

How to get the string name only.

FYI: the name changes every time.

@vishnu_prasad21,

Try like this

Path.GetFileNameWithoutExtension("C:\users\training\documents\excel1.xlsx ")

Hi,

You can try using

str = str.Substring(str.LastIndexOf(""))

Thanks

put \ in the Quotations

Thank @sarathi125 it works fine!

Thank you for the help! :blush:

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