How can I use an array in a try-catch and in a subsequent try-catch as well?

RobinJ 276 Reputation points
2021-02-13T10:07:02.82+00:00

Why can't I use the array "server_tokens_array" in the Array.IndexOf(server_tokens_array, token input)?
Can someone help me?

 try
                    {
                        string[] server_tokens = File.ReadAllLines(@$"{localappdata}\Liquid Aqua\API\server_token.txt");
                        Array server_tokens_array = server_tokens;
                    }
                    catch
                    {
                        if (System.IO.File.Exists(server_token_datei))
                        {
                            //Server Token datei löschen
                            System.IO.File.Delete(server_token_datei);
                        }

                        System.Windows.MessageBox.Show("Datei konnte nicht gelesen werden. Bitte erneut Versuchen.", caption_file_read, button_ok);
                        fortschritt_label.Content = null; progress_bar.Value = 0; api_token.Text = std_text_token;
                        return;
                    }

                    //Überprüfung Token server_token_string.Contains(token_eingabe)
                    try
                    {
                        int pos = Array.IndexOf(server_tokens_array, token_eingabe);
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,503 questions
0 comments No comments
{count} votes

0 additional answers

Sort by: Most helpful