Hey guys,
sorry to post an error message, but I am really having trouble here. I have a c# winforms project that gets this error message:
************** Exception Text **************
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at SlashA006.Form1.IdCheck() in C:\Users\John\Desktop\John\SCAR\OperationMonkeyRaider-v2\visual studio\real\SlashA006 f\SlashA006\SlashA006\Form1.cs:line 180
at SlashA006.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\John\Desktop\John\SCAR\OperationMonkeyRaider-v2\visual studio\real\SlashA006 f\SlashA006\SlashA006\Form1.cs:line 64
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
So I did some research, I guess this error means some variable types could be mixed around, but I have no idea what to do and I can't find anything relavent online. My code for lines 64-180 is:
line 64:
IdCheck();
line 180:
public void IdCheck()
{
string currentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)+ @"\SlashA006";
string path = currentDirectory + @"\saveData.txt";
if (!File.Exists(path))
{
var saveDataFile = File.Create(path);
saveDataFile.Close();
int id = IDsetup();
TextWriter tw = new StreamWriter(path);
tw.WriteLine(id.ToString());
tw.Close();
computerID = id;
this.Visible = true;
System.Windows.Forms.MessageBox.Show("ID is: " + id);
func_wait_3("500");
this.Visible = false;
}
if (File.Exists(path))
{
bool success = int.TryParse(File.ReadAllText(path), out int idRead);
computerID = idRead;
}
}
Once again, sorry for a newb question, but I'd really appreciate any help. Thanks!
What I have tried:
As I said above, I tried looking online for examples of this problem but to no avail. I changed line 180 from parse to tryparse, but that didn't work either.