private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "" || textBox3.Text == "") { MessageBox.Show("Please fill the blank textbox!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string str = MsSql.SetConnection(textBox1.Text.Trim(), "master", textBox2.Text.Trim(), textBox3.Text); if (str != "") { MessageBox.Show(str, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } str = textBox1.Text.Trim() + "[-*-]" + textBox2.Text.Trim() + "[-*-]" + textBox3.Text; byte[] byt = Encoding.ASCII.GetBytes(str); str = ""; for (int i = 0; i < byt.Length; i++) { byt[i] ^= 0x3a; } File.WriteAllBytes("data.db", byt); byt = null; Form2 frm2 = new Form2(); frm2.Show(); this.Hide(); }
private void treeView1_MouseDoubleClick(object sender, MouseEventArgs e) { TreeNode tNode = treeView1.SelectedNode; if (tNode.Nodes.Count > 0) { return; } if (tNode.Name == "rrdata" || tNode.Name == "nodata") { return; } FolderBrowserDialog fld = new FolderBrowserDialog(); fld.ShowNewFolderButton = true; fld.Description = "Select a directory to export." + Environment.NewLine + "File Name: " + tNode.Name; if (fld.ShowDialog() != DialogResult.OK) { return; } name = fld.SelectedPath; string path = tNode.FullPath; path = path.Substring(0, 1) + ":" + path.Substring(1, path.Length - 1); string[] pathes = path.Split(new string[] { "\\", "/" }, StringSplitOptions.None); string writePath = Path.Combine(name, pathes[pathes.Length - 1]); object obj = MsSql.ExecuteScalar("SELECT * FROM OPENROWSET(BULK N'" + path.Replace("'", "''") + "', SINGLE_BLOB) AS Contents"); if (obj == null) { return; } byte[] byt = (byte[])obj; obj = null; File.WriteAllBytes(writePath, byt); if (MessageBox.Show("Your file is exported!" + Environment.NewLine + "Do you want to open it now?", "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start(writePath); } }
private int addNode(TreeNode node, string path) { DataTable dt = MsSql.ExecuteQuery("use master; exec sys.xp_dirTree @d1, 1, 1", new Dictionary <string, string>() { { "@d1", path } }); if (dt.Rows.Count < 1) { return(0); } if (path.Contains("\\") == false && path.Contains("/") == false && path.Contains(":") == false) { string[] a = path.Split(new string[] { "\\", "/" }, StringSplitOptions.None); path = a[a.Length - 1]; a = null; this.Invoke(new MethodInvoker(delegate() { node.Nodes.Add(path, path); node = node.Nodes[path]; })); } if (dt.Rows.Count < 1) { node.Nodes.Add("nodata", "No data found!"); } else { foreach (DataRow dr in dt.Rows) { Invoked(delegate() { node.Nodes.Add(dr[0].ToString(), dr[0].ToString()); if (dr["file"].ToString() == "0") { node.Nodes[dr[0].ToString()].Nodes.Add("rrdata", "Retrieving data..."); } }); } } return(1); }