How to get the extension only for a specific file

Hi everyone
I have an excel file in my folder, I already checked if it exists or not.
now I want to get the extension of the file because if I will use a “read range” without the correct extension it will crash…
Please help me fix this

have a look here:

I looked and I’m not sure that its answers my Q
I want to do a “read range” but I don’t know the extension of the file (I don’t see the extension on the saved file in the folder), and when I tried to run it - it did an error that it’s not exist (and when I tried a specific extension it did worked)
so I wanna know what I need to use so it won’t crash, or maybe a suggestion how to fix it…

did sound like you are interrested to retrieve the extension for a file and based on an evalutation if it is having the right extension it should be processed or not. Maybe your case is different or was not understood properly by me

@dlichtenstadt In If activity type condition Path.GetExtension(filepath).
Filepath would be the same as you have passed while checking if file exists or not. This will give you a extension e.g. xls, xlsx of that file

Thanks for the answer
I tried it
and when the file doesn’t have a visible extension (for example: “excel”, this is with visible extension: “excel.xls”) it shows like the file doesn’t have an extension at all

as u can see the “read range” didn’t worked, the extension wasn’t found, because the file doesn’t have a visible extension

@dlichtenstadt If you don’t have the extension xls, xlsx or xlsm in your excel file then you can not use Read Range in both way Excel application scope and workbook activities

@dlichtenstadt Here visible extension means what not showing extension in file explorer or don’t have extension

didn’t understand what u said
can u explain it please?

so what can I do, if I will open the properties option - it will show the extension there.
so what can I do to make sure that the “read range” won’t collapse?

@dlichtenstadt Can you please share a screenshot of property window

sorry for the Hebrew

Hello @dlichtenstadt. i also dropped this on your previous post. This would also help here to. i used Path.GetExtension(YourFilePath) please find attached again
CheckFile.zip (27.4 KB)

I will check it
thank u very much
P.S
thought it was simpler than what u sent me…

1 Like

I checked what u sent me
I added the option of “.xls”
but how do I know that I covered all the options of excel extension?