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,888 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
is it possible to check if only one line of the stringbuilder matches to another string?
//Server Token Datei lesen
string server_token_string;
using (StreamReader sr = new StreamReader(@$"{localappdata}\Liquid Aqua\API\server_token.txt", Encoding.Default))
{
StringBuilder server_tokens = new StringBuilder();
// schreibt Zeile für Zeile auf den StringBuilder bis das Ende der Datei erreicht ist
while (!sr.EndOfStream)
server_tokens.AppendLine(sr.ReadLine()); fortschritt_label.Content = "Reading Server File..."; progress_bar.Value = 6;
server_token_string = server_tokens.ToString();
}
//Überprüfung Token
if (server_token_string == token_eingabe)
{
title_label.Content = "Gültiger API-Token. Viel Spass mit Liquid Aqua"; fortschritt_label.Content = "API-Check successful finished."; progress_bar.Value = 8;
Environment.Exit(0);
}
else
{
//Ungültiger Token
title_label.Content = @$"Ungültiger Token {token_eingabe}. Bitte erneut versuchen."; progress_bar.Value = 0; fortschritt_label.Content = $"Ungültiger Token {token_eingabe}. Bitte erneut versuchen.";
}
It isn't clear (to me) exactly what you want to check.
Do you want to check if one specific line within the StringBuilder object,
or the string created from it using ToString(), matches another string?
Or do you want to check if any line in the string (or SB) matches
another string?
If the latter, you can use the Contains() method on the string created from
the SB. e.g. -
server_token_string = server_tokens.ToString();
//if (server_token_string == token_eingabe)
if (server_token_string.Contains(token_eingabe))