//판자식 보호 우클릭 (명령어 , 타겟 프로그램의 폴더 경로) public void rightClick(string command, string target_folder_dir) { //dos 창을 사용을 위한 세팅 System.Diagnostics.ProcessStartInfo proinfo = new System.Diagnostics.ProcessStartInfo(); System.Diagnostics.Process pro = new System.Diagnostics.Process(); proinfo.FileName = @"cmd"; proinfo.CreateNoWindow = true; //띄우기 안띄우기 proinfo.UseShellExecute = false; proinfo.RedirectStandardOutput = true; proinfo.RedirectStandardInput = true; proinfo.RedirectStandardError = true; pro.StartInfo = proinfo; pro.Start(); //명령어에 따라 보호 or 해제 if (command.Equals("protect")) { //폴더 하이딩 pro.StandardInput.Write("attrib " + target_folder_dir + " +r +s +h" + Environment.NewLine); //Warning //cmd 실행속도 고려 System.Threading.Thread.Sleep(500); icon shortcut = new icon(); shortcut.createShortcut(Environment.CurrentDirectory, Path.GetFileName(target_folder_dir)); //AccessAuthority auth = new AccessAuthority(target_folder_dir); //auth.folderSecu_Test3(); shortcut.panja_inherit_delete(target_folder_dir); //MessageBox.Show("Target : " + address + "\n" + "shortcut a : " + Environment.CurrentDirectory + "\n shortcut b :" + Path.GetFileName(address)); hex_handler new_hex = new hex_handler(); int length = new_hex.hex_length(); int start_point = 0x499; for (int h = 0; h < length; h++) { start_point += 0x100; } new_hex.hex_write(target_folder_dir, start_point); new_hex.hex_length_set(length + 1); } else if (command.Equals("recover")) { panja_recover(target_folder_dir); } pro.StandardInput.Close(); string resultValue = pro.StandardOutput.ReadToEnd(); //cmd 종료 pro.Close(); }
private void Local_Minus_Load(object sender, EventArgs e) { //폼실행시 기준 경로가 파일이라 ㄱㅊ //string[] allLines = File.ReadAllLines(@"C:\Temp\test.txt", Encoding.Default); string[] allLines = new_list; hex_handler hex = new hex_handler(); int hex_length = hex.hex_length(); int start_point = 0x500; //string[] allLines = new string[j]; allLines[0] = hex.hex_read(0x500); for (int y = 0; y < hex_length; y++) { allLines[y] = hex.hex_read(start_point); start_point += 0x100; } MessageBox.Show("얻은 길이 " + hex.hex_length()); int i; for (i = 0; i < hex_length; i++) { if (!allLines[i].Equals("")) { FolderAccess access = new FolderAccess(); //access.panja_inherit_recover(allLines[i]); } TreeNode rootNode = new TreeNode(allLines[i]); //rootNode.Text = allLines[i]; rootNode.ImageIndex = 2; rootNode.SelectedImageIndex = 2; List_own.Nodes.Add(rootNode); } List_own.FullRowSelect = true; /* * int i; * for (i = 0; i < allLines.Length; i++) * { * TreeNode rootNode = new TreeNode(allLines[i]); * //rootNode.Text = allLines[i]; * rootNode.ImageIndex = 2; * rootNode.SelectedImageIndex = 2; * List_own.Nodes.Add(rootNode); * //Fill(rootNode, allLines[i]); * } */ }
private void button3_Click(object sender, EventArgs e) { if (List_go.Items.Count != 0) { System.Diagnostics.ProcessStartInfo proinfo = new System.Diagnostics.ProcessStartInfo(); System.Diagnostics.Process pro = new System.Diagnostics.Process(); proinfo.FileName = @"cmd"; proinfo.CreateNoWindow = false; //띄우기 안띄우기 proinfo.UseShellExecute = false; proinfo.RedirectStandardOutput = true; proinfo.RedirectStandardInput = true; proinfo.RedirectStandardError = true; pro.StartInfo = proinfo; pro.Start(); hex_handler hex = new hex_handler(); int i; length = hex.hex_length(); //added 폴더 int lastnum = List_go.Items.Count; string target_dir; for (i = 0; i < length; i++) { for (int z = 0; z < lastnum; z++) { if (new_list[i] == List_go.Items[z].Text) { target_dir = new_list[i]; new_list[i] = null; hex.hex_length_set(hex.hex_length() - 1); //윤식 : 이부분 input ACL FolderAccess rgs = new FolderAccess(); if (new_list[i] == null) { rgs.panja_inherit_recover(target_dir); pro.StandardInput.Write("attrib " + '\u0022' + target_dir + '\u0022' + " -r -s -h" + Environment.NewLine); } } } } //length = hex.hex_length(); int start_point = 0x500 - 0x001; for (int j = 0; j < length; j++) { if (new_list[j] == null) { continue; } hex.hex_write1(new_list[j], start_point); start_point += 0x100; //System.IO.File.AppendAllText(@"C:\Temp\test.txt", Environment.NewLine + folder_path[i] , Encoding.Default); } pro.StandardInput.Close(); pro.Close(); this.Close(); } }
private void proctect_click(object sender, EventArgs e) { //int count = 0; int i; //added 폴더 int lastnum = selectlist.Items.Count; if (lastnum != 0) { //JObject json = new JObject(); //JArray jjson = new JArray(); //string file_name, file_byte, file_link; //string[] file_save = new string[1000]; for (i = 0; i < lastnum; i++) { //added_Folder : 해당 보호폴더 첫 헤더 폴더 (타겟폴더) added_Folder[i] = selectlist.Items[i].Text; folder_path[i] = added_Folder[i]; //Console.WriteLine(added_Folder[i]); //string dirPath = added_Folder[i]; if (upload_chk.Checked == true) { Name = Path.GetFileName(selectlist.Items[i].Text); sftp = new SftpClient(host, username, password); sftp.Connect(); sftp.CreateDirectory("./folder1/" + Name); UploadDirectory(sftp, selectlist.Items[i].Text, "./folder1/" + Name); sftp.Disconnect(); MessageBox.Show(Name + "가 클라우드 저장소에 업로드 되었습니다."); } /* * string[] files = Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories); * foreach (string s in files) * { * Console.WriteLine(s); * file_save[count++] = s; * * } */ } /* * for (i = 0; i < count - 1; i++) * { * file_info file_Inf = new file_info(file_save[i]); * Console.WriteLine(file_Inf.fname); * * json = JObject.FromObject(file_Inf); * jjson.Add(json); * * } * * * * * json.Add("link", jjson); * //리스트로 저장 * //IList<file_list> save_json = json.ToObject<IList<file_list>>(); * * // write JSON directly to a file * using (StreamWriter file = File.CreateText(@"C:\Temp\file_list.json")) * using (JsonTextWriter writer = new JsonTextWriter(file)) * { * json.WriteTo(writer); * } * * //저장한파일 클라우드의 유저디렉토리에 저장 * Filecontrol fi = new Filecontrol(); * //fi.Put_json(); * * * for (i = 0; i < lastnum; i++) * { * fi.Put_json(folder_path[i]); * } */ hex_handler hex = new hex_handler(); int totalnum = hex.hex_length(); string[] all_string = new string[totalnum + lastnum]; int num; for (num = 0; num < totalnum; num++) { all_string[num] = new_list[num]; } int k = 0; for (i = 0; i < lastnum; i++) { Register rgs = new Register(); // 임시 폴더용 코드임 //string absPRo = @"C:\Temp\test.txt"; for (num = totalnum; num < lastnum + totalnum; num++) { if (k != lastnum) { all_string[num] = added_Folder[k]; k++; } } //프로젝트 기반 상대경로 //property 상대경로 불러오는 코드 //Register rgs = new Register(); //string[] absExcuteDir = rgs.getAbsDir().Split('\\'); //string absPro = ""; //for (int k = 0; k < absExcuteDir.Length - 3; k++) //{ // absPro += absExcuteDir[k]; // absPro += @"\"; //} //absPro += @"Properties\test.txt"; //System.IO.File.AppendAllText(absPro, "\n" + folder_path[i], Encoding.Default); } int start_point = 0x500 - 0x001; for (num = 0; num < lastnum + totalnum; num++) { hex.hex_write1(all_string[num], start_point); start_point += 0x100; //System.IO.File.AppendAllText(@"C:\Temp\test.txt", Environment.NewLine + folder_path[i] , Encoding.Default); } hex.hex_length_set(totalnum + lastnum); //-------------------------------폴더보호 System.Diagnostics.ProcessStartInfo proinfo = new System.Diagnostics.ProcessStartInfo(); System.Diagnostics.Process pro = new System.Diagnostics.Process(); proinfo.FileName = @"cmd"; proinfo.CreateNoWindow = true; //띄우기 안띄우기 proinfo.UseShellExecute = false; proinfo.RedirectStandardOutput = true; proinfo.RedirectStandardInput = true; proinfo.RedirectStandardError = true; pro.StartInfo = proinfo; pro.Start(); for (i = 0; i < lastnum; i++) { Console.WriteLine(folder_path[i]); //----------------------------------------- //윤식 : 이부분 input ACL pro.StandardInput.WriteLine("attrib " + '\u0022' + folder_path[i] + '\u0022' + " +r +s +h" + Environment.NewLine); icon rgs = new icon(); rgs.createShortcut(Path.GetDirectoryName(folder_path[i]), Path.GetFileName(folder_path[i])); //rgs.panja_protect(folder_path[i]); MessageBox.Show("Inherit Delete Excution"); rgs.panja_inherit_delete(folder_path[i]); } pro.StandardInput.Close(); pro.Close(); this.Close(); } }
void treeview_fill() { hex_handler hex = new hex_handler(); //string absTemp = @"C:\Users\rooto\Source\Repos\Panja_Project\Panja_Project\Properties"; //삭제 //absPro = @"C:\Program Files (x86)\Default Company Name\SetupSample\Panja\Properties\test.txt"; //확인용 //MessageBox.Show("얻은 문자열 " + hex.hex_read(0x500)); /* * * string[] allLines = File.ReadAllLines(absPro, Encoding.Default); * * int i; * for (i = 0; i < allLines.Length; i++) * { * if (!allLines[i].Equals("")) * { * FolderAccess access = new FolderAccess(); * access.panja_inherit_recover(allLines[i]); * } * TreeNode rootNode = new TreeNode(allLines[i]); * //rootNode.Text = allLines[i]; * rootNode.ImageIndex = 2; * rootNode.SelectedImageIndex = 2; * treeView1.Nodes.Add(rootNode); * Fill(rootNode, allLines[i]); * } */ int j = hex.hex_length(); int start_point = 0x500; //string[] allLines = new string[j]; allLines[0] = hex.hex_read(0x500); for (int y = 0; y < j; y++) { allLines[y] = hex.hex_read(start_point); start_point += 0x100; } //MessageBox.Show("얻은 길이 " + hex.hex_length()); int i; for (i = 0; i < j; i++) { if (!allLines[i].Equals("")) { FolderAccess access = new FolderAccess(); //access.panja_inherit_recover(allLines[i]); } TreeNode rootNode = new TreeNode(allLines[i]); //rootNode.Text = allLines[i]; rootNode.ImageIndex = 2; rootNode.SelectedImageIndex = 2; treeView1.Nodes.Add(rootNode); Fill(rootNode, allLines[i]); } listView1.FullRowSelect = true; }