Yes, I know, but I don't know why it's finding the index of \r\n to be -1, it's definitely there...
I just checked the input from textBox_Quantity.Text, and it's "". However, as I said when I manually check textBox_Quantity.Text it shows "1\r\n"

I didn't work with C# in ages but from other languages at least \r\n are control chars so you need to use ' instead of " else it gets misinterpreted. Also check the encoding of your .xml file. (I work with Linux mostly so not sure which are which on Windows but I often have this problem with files created on Windows and then being used on Linux) This is a bit tricky but fiddle around a bit with it and you will eventually work it out.

Alternatively and less neat, you can iterate through the string and check if it is an int char or not and break on mismatch.

Hello, my guess would be that the "quantity" is sometimes empty string. Which means it sometimes gives you the value 1\r\n and sometimes it crashes with the error.
I have found a non-crashing solution in this question:What is the easiest way in C# to trim a newline off of a string? - Stack Overflow
The code you might need is:
textBox_Quantity.Text = quantity;
int quantityInt = System.Convert.ToInt32(quantity.TrimEnd( Environment.NewLine.ToCharArray()));