I am using discord auto joiner, and when the discord is not found in the pc. It shows an exception result in breaking the whole UI and messing stuff up.
Now in order to do that I tried using catch exception but it won't work for public static string, it only work for public static void. Then I tried if file exists. Same thing with that.
This is my code....
public static string GetToken(string path, bool isLog = false)
{
if (File.Exists(path))
{
byte[] bytes = File.ReadAllBytes(path);
string @string = Encoding.UTF8.GetString(bytes);
string text = "";
string text2 = @string;
while (text2.Contains("oken"))
{
string[] array = Sub(text2).Split(new char[]
{
'"'
});
text = array[0];
text2 = string.Join("\"", array);
if (isLog && text.Length == 59)
{
break;
}
}
return text;
}
}
I just want to remove the exception.