internal static void ReadConfigFile() { string[] dati = null; try { #if DEBUG dati = TextFile.FileToArray(Commons.PathAndFileConfig + "_DEBUG"); #else dati = TextFile.FileToArray(Commons.PathAndFileConfig); #endif if (dati != null) { Commons.FileDatabase = dati[0]; Commons.PathImages = dati[1]; Commons.PathStartLinks = dati[2]; // not longer used; left for compatibility of configuration file Commons.PathDatabase = dati[3]; Commons.PathAndFileDatabase = Commons.PathDatabase + "\\" + Commons.FileDatabase; Commons.PathDocuments = dati[4]; // we try the next to avoid stopping the program whe a new config file, // with another field will show up. You have to add some data in.config file. try { Commons.SaveBackupWhenExiting = bool.Parse(dati[5]); } catch { } } } catch { // if error do nothing. the rest of the code will generate the default data } }
private void btnImportTopics_Click(object sender, EventArgs e) { // !!!! TODO fix using Regex.Split(string, ...) !!!! MessageBox.Show("To fix!"); return; List <Topic> ListTopics = new List <Topic>(); string[] topics = TextFile.FileToArray(Commons.PathDatabase + "\\Argomenti_DA IMPORTARE.tsv"); if (topics == null) { MessageBox.Show("Non è stato possibile aprire il file Argomenti_DA IMPORTARE.tsv"); return; } foreach (string line in topics) { Topic t = new Topic(); string[] fields = line.Split('\t'); // count tabs in the beginning of the line int nTabs = 0; while (fields[nTabs] == "" && nTabs < fields.Length - 1) { nTabs++; } if (fields[nTabs] != "") { // store temporarily the level in field Parent node ID // (not used for other in this phase) t.ParentNodeNew = nTabs; // it is the level count t.Name = fields[nTabs++]; if (nTabs < fields.Length && fields[nTabs] != "") { t.Desc = fields[nTabs]; } ListTopics.Add(t); } } MessageBox.Show("Salvare per rendere definitiva l'importazione."); frmTopics ft = new frmTopics(frmTopics.TopicsFormType.ImportWithErase, ListTopics, null, null); ft.ShowDialog(); ft.Dispose(); }