Hello, I have these following classes:
Then I have this for form 1:
It loads this file:
And it stops on this line:
I don't have a single clue why, I'm very experienced with C# and I can't figure this one out for the life of me, it just stops code, stops functioning, I just see the form and no function runs or anything, after it stops after that line it just "stops", I tried removing the special characters from the file and that didn't work, what's going on?
Code:
public class languageConverter
{
public Dictionary<string, language> languages = new Dictionary<string, language>();
public void loadLanguages()
{
string[] languageFiles = Directory.GetFiles(Application.StartupPath + "/languages/");
foreach (string langFile in languageFiles)
{
Console.WriteLine(langFile);
language newLang = new language();
using (StreamReader sr = new StreamReader(langFile))
{
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
Console.WriteLine(line);
string lType = line.Split(':')[0];
string lAnswer = line.Split(':')[1];
if (lType == "name") newLang.name = lAnswer;
else if (lType == "word") newLang.words.Add(lAnswer.Split(',')[0], lAnswer.Split(',')[1]);
else if (lType == "shortcut") newLang.shortcutWords.Add(lAnswer.Split(',')[0], lAnswer.Split(',')[1]);
}
}
languages.Add(newLang.name, newLang);
}
}
}
public class language
{
public string name;
public Dictionary<string, string> words = new Dictionary<string, string>();
public Dictionary<string, string> shortcutWords = new Dictionary<string, string>();
}
Code:
public partial class Form1 : Form
{
languageConverter lConverter = new languageConverter();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
lConverter.loadLanguages();
}
}
Code:
name:danish
word:i,jeg
word:will,vil
word:how,hvordan
word:hi,hej
word:hello,hej
word:hey,hej
word:name,navn
word:my,min
word:is,er
word:was,var
word:this,dette
word:a,en
word:you,du
word:love,kærlighed
word:very,meget
word:much,meget
word:danish,Dansk
word:very-much,meget
word:want,ønsker
word:to,til
word:know,kende
word:are,er
word:who,der
word:would-like,vil gerne
word:i-would-like-to,jeg vil gerne
word:who,hven
word:i-would-like-to-know,jeg vil gerne vide
shortcut:very much,very-much
shortcut:would like,would-like
shortcut:i would like to,i-would-like-to
shortcut:i would like to know,i-would-like-to-know
Code:
word:who,hven