How to handle this kind of Error: Index was outside the bounds of array

I am trying the split the amount value using “EUR” from filename while splitting this i am getting some error please find all the screenshots arranged sequentially

Screenshot 2021-04-16 201902 Screenshot 2021-04-16 201932 Screenshot 2021-04-16 201957

Thanks in advance

Probably you are trying to access a position that does not exist in your array. What is file variable returning? Is it returning the correct name of your file?

Edit: Have you already tried this way: Split(file, “EUR”)(0).ToString ?

Try below.

yourResult = varStr.Split(new string[] { "EUR" }, StringSplitOptions.None)(1).ToString

Hi @rsr.chandu

Try this


Ignore my above comment


Yes, it is returning the file name

Again it is throwing error

It is also throwing error

@rsr.chandu - If you are looking to extract the last amount before the .pdf then you can use the below pattern…


You can assign this to a string value.

Please find the sample below:

1 Like

Hi I used the same
but i am not getting that, please find the below screenshots

Screenshot 2021-04-19 103605


Can you share the above regex sample workflow (Sequence1.xaml) as a file?
Probably we need accurate string data.


Sequence1.xaml (7.8 KB)


Thank you for your sharing the file.
However, we need string data. So can you share the following file?(we need to know content of fn variable.)


E735, 78451, Continental AG,Verwaltung VVA, 05.10, EUR 32.832,54.pdf (26.4 KB)


Thank you for sharing the file.
I checked it using regex pattern which @prasath17 mentioned, and it works.

Sequence1.xaml (5.0 KB)

First, can you try the above sample?

Next, if it works, can you check is there any difference between the above filename and your filename using WriteLine activity to output filename?


1 Like


If it is a throwing error means the keyword is not present in the string or you are doing something wrong…Otherwise, it is impossible to throw errors.

I saw all the solutions and those are very nice but you need to put more effort to do the exception handling in either case.

Check IF EUR is present in the string before splitting the data.
If varStr.contains(“EUR”) then to split

I would suggest to go ahead with solution by @prasath17 if looking for amount and also REGEX expressions are more feasible than string operations

Е972 , 25040 , Rheinmetall Electronics GmbH, 06.01, ЕUR 266.677,29.pdf (22.4 KB)

Can you try this last one

@rsr.chandu …in your screenshot I could see - inside the square bracket right.? If yes it should be . Please use copy icon to copy the code and paste it. It should work.

Hi @rsr.chandu

In ‘f1’ assign, please change it as path.GetFileNameWithoutExtension(file)

in ‘f2’ assign, f1.Replace(“ЕUR”,“&”).Split("&"c)(1)

Note: f1 variable type should be array[string], f2 variable type should be string.


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