private void ReadIniFileSub() { string strReadBuffer = ""; List <string> strListBuffer = new List <string>(); string strLinkbuffer = ""; strReadBuffer = INI_Library.GetValue("Folder", "Folders", Sys.strIniFilePath); string[] strFoldersArray = strReadBuffer.Split(','); AddTreeViewParentNodeFunc(strFoldersArray); for (int i = 0; i < strFoldersArray.Length; i++) { strListBuffer = INI_Library.GetKeys(strFoldersArray[i], Sys.strIniFilePath); Sys.i32NumOfFolders++; for (int j = 0; j < strListBuffer.Count; j++) { tvw_BookmarkName.Nodes[i].Nodes.Add(strListBuffer[j]); strLinkbuffer = INI_Library.GetValue(strFoldersArray[i], strListBuffer[j], Sys.strIniFilePath); DataGridViewAddRowFunc(Sys.i32NumOfBookmark, strFoldersArray[i], strListBuffer[j], strLinkbuffer); Sys.i32NumOfBookmark++; } strListBuffer.Clear(); } UpdateDataGridViewFunc(dgv_BookmarkList); }
private void tvw_BookmarkName_AfterSelect(object sender, TreeViewEventArgs e) { string strLink = ""; string strReadBuffer = ""; string[] strFoldersArray; bool bContainsFolder = false; if (tvw_BookmarkName.SelectedNode != null) { strReadBuffer = INI_Library.GetValue("Folder", "Folders", Sys.strIniFilePath); strFoldersArray = strReadBuffer.Split(','); bContainsFolder = strFoldersArray.Contains(tvw_BookmarkName.SelectedNode.Text); if (bContainsFolder == false) { //Child Node //MessageBox.Show(tvw_BookmarkName.SelectedNode.Text); strLink = INI_Library.GetValue(e.Node.Parent.Text.ToString(), tvw_BookmarkName.SelectedNode.Text.ToString(), Sys.strIniFilePath); //MessageBox.Show(strLink); System.Diagnostics.Process.Start(strLink); StaticVariables.StrSectionName = e.Node.Parent.Text.ToString(); StaticVariables.StrKey = tvw_BookmarkName.SelectedNode.Text.ToString(); StaticVariables.StrValue = strLink; } } }
private void WriteDefaultIniFileSub() { if (!File.Exists(Sys.strIniFilePath)) { //using (File.Create(Sys.strIniFilePath)) { }; var utf8WithoutBom = new System.Text.UTF8Encoding(false); using (var sink = new StreamWriter(Sys.strIniFilePath, false, utf8WithoutBom)) { sink.WriteLine("; UTF8 Without BOM "); } } INI_Library.SetValue("Folder", "Folders", "Movie,Blog", Sys.strIniFilePath); INI_Library.SetValue("Movie", "SubHD", "http://subhd.com/", Sys.strIniFilePath); INI_Library.SetValue("Blog", "我的博客", "https://jack-a-lent.github.io/", Sys.strIniFilePath); }
private void btn_Enter_Click(object sender, EventArgs e) { string strIniFilePath = Application.StartupPath + "\\Bookmark.ini"; string strReadBuffer = ""; string[] strFoldersArray; bool bContainsFolder = false; if (StaticVariables.bIsAddForm == true) { if ((tb_Folder.Text == "") || (tb_Name.Text == "") || (tb_Link.Text == "")) { MessageBox.Show("请输入内容!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { INI_Library.SetValue(tb_Folder.Text, tb_Name.Text, tb_Link.Text, strIniFilePath); strReadBuffer = INI_Library.GetValue("Folder", "Folders", strIniFilePath); strFoldersArray = strReadBuffer.Split(','); bContainsFolder = strFoldersArray.Contains(tb_Folder.Text); if (bContainsFolder == false) { strReadBuffer += "," + tb_Folder.Text; INI_Library.SetValue("Folder", "Folders", strReadBuffer, strIniFilePath); } MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if ((tb_Folder.Text == "") || (tb_Name.Text == "") || (tb_Link.Text == "")) { MessageBox.Show("请先选择内容!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { INI_Library.Removekey(tb_Folder.Text, tb_Name.Text, strIniFilePath); MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //this.Close(); } } }