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(); } }