/// <summary> /// Set current key. /// </summary> private void SetCurrentKey() { if (NewPath.Trim().Length > 0) { if (OldPath.Trim().Length > 0) { _currentKey = "[" + NewPath + "]-[" + OldPath + "]"; } else { _currentKey = "[" + NewPath + "]-[?]"; } } else { if (OldPath.Trim().Length > 0) { _currentKey = "[?]-[" + OldPath + "]"; } else { _currentKey = string.Empty; } } }
/// <summary> /// /// </summary> /// <param name="applicationPath"></param> /// <param name="type"></param> internal void FormatPath(string applicationPath, string type) { // Pour l'instant le chemin relatif aura une allure de chemin absolu si les lecteurs sont différents if (OldPath.StartsWith('.')) { HardPath = Path.GetFullPath(OldPath, Global.LaunchBoxRoot); RelatPath = OldPath; } // Hardlink else if (OldPath.Contains(':')) { HardPath = OldPath; RelatPath = DxPath.To_Relative(Global.LaunchBoxRoot, OldPath); // OldRelatPath = Path.GetRelativePath(Global.LaunchBoxPath, OldPath); } // Cas spécial quand ça commence par un nom de folder (Games ne l'utiliserait pas) // Si c'est vide ça le transforme en .\ else { /*OldHardPath = OldPath; * OldRelatPath = DxPath.ToRelative(Global.LaunchBoxRoot, OldPath);*/ // Cas de figure ou c'est à la racine de Launchbox HardPath = Path.Combine(Global.LaunchBoxRoot, OldPath); //OldRelatPath = @$".\{OldPath}"; RelatPath = DxPath.To_Relative(Global.LaunchBoxRoot, HardPath); } }
public override int GetHashCode() { unchecked { return(((OldPath != null ? OldPath.GetHashCode() : 0) * 397) ^ (NewPath != null ? NewPath.GetHashCode() : 0)); } }
private void Button_Save_Click(object sender, EventArgs e) //변경적용 버튼 { string OldPath; //기존 경로 string NewPath; //옮길 경로 string AddName; //바꿀 이름 int fail_Count_exist = 0; //변경적용 실패 카운트 int fail_Count_file = 0; int fail_Count_folder = 0; int fail_Count_Length = 0; int fail_Count_ZeroLength = 0; int fail_Number_exist; int fail_Number_file; int fail_Number_folder; int fail_Number_Length; int fail_Number_ZeroLength; string fail_List_exist = ""; string fail_List_file = ""; string fail_List_folder = ""; string fail_List_Length = ""; string fail_List_ZeroLength = ""; int error_count = 0; for (int i = 0; i < listView1.Items.Count; i++) { ListViewItem item = listView1.Items[i]; if (listView1.Items[i].SubItems[0].Text != listView1.Items[i].SubItems[1].Text) //기존 파일명과 변경할 이름이 달라야 적용 { AddName = item.SubItems[1].Text; //변경할 이름 OldPath = item.SubItems[2].Text; //기존 경로 NewPath = (OldPath.Substring(0, OldPath.LastIndexOf("\\") + 1)); NewPath = NewPath + AddName; //변경할 경로(파일명 변경) if (FileExistsCheck(OldPath) == false && FolderExistsCheck(OldPath) == false) //파일이 해당 경로에 없는 경우 에러 카운트 { fail_Count_exist++; //해당 경로에 없는 목록 개수 기록 fail_Number_exist = i + 1; if (fail_Count_exist > 1) //해당 경로에 없는 목록 순서 기록 { fail_List_exist = fail_List_exist + ", " + fail_Number_exist.ToString(); } else if (fail_Count_exist == 1) { fail_List_exist = fail_Number_exist.ToString(); } else { error_count++; } } else if (FileExistsCheck(NewPath) == true)//이미 해당 이름을 가진 파일이 존재할 경우 { fail_Count_file++; fail_Number_file = i + 1; if (fail_Count_file > 1) { fail_List_file = fail_List_file + ", " + fail_Number_file.ToString(); } else if (fail_Count_exist == 1) { fail_List_file = fail_Number_file.ToString(); } else { error_count++; } } else if (FolderExistsCheck(NewPath) == true)//이미 해당 이름을 가진 폴더가 존재할 경우 { fail_Count_folder++; fail_Number_folder = i + 1; if (fail_Count_folder > 1) { fail_List_folder = fail_List_folder + ", " + fail_Number_folder.ToString(); } else if (fail_Count_folder == 1) { fail_List_folder = fail_Number_folder.ToString(); } else { error_count++; } } else if (NewPath.Length >= 260)//이름 길이가 너무 길 경우 { fail_Count_Length++; fail_Number_Length = i + 1; if (fail_Count_Length > 1) { fail_List_Length = fail_List_Length + ", " + fail_Number_Length.ToString(); } else if (fail_Count_Length == 1) { fail_List_Length = fail_Number_Length.ToString(); } else { error_count++; } } //이름 길이가 너무 짧은 경우 else if (FolderExistsCheck(OldPath) == true ? AddName.Length == 0 : AddName.Contains(".") ? AddName.Substring(0, AddName.LastIndexOf(".")).Length == 0 : AddName.Length == 0) { fail_Count_ZeroLength++; fail_Number_ZeroLength = i + 1; if (fail_Count_ZeroLength > 1) { fail_List_ZeroLength = fail_List_ZeroLength + ", " + fail_Number_ZeroLength.ToString(); } else if (fail_Count_ZeroLength == 1) { fail_List_ZeroLength = fail_Number_ZeroLength.ToString(); } else { error_count++; } } else if (FileExistsCheck(OldPath) == true)//파일 이름 변경 { System.IO.File.Move(OldPath, NewPath); item.SubItems[0].Text = AddName; item.SubItems[2].Text = NewPath; } else if (FolderExistsCheck(OldPath) == true)//폴더 이름 변경 { System.IO.Directory.Move(OldPath, NewPath); item.SubItems[0].Text = AddName; item.SubItems[2].Text = NewPath; } else { error_count += 100000;//예기치 못한 에러 체크 } } } if (fail_Count_exist > 0 && fail_Count_file > 0 && fail_Count_folder > 0)//파일명 변경 할 수 없는 목록 개수와 순서 알림 { MessageBox.Show(fail_Count_exist + "개의 파일 또는 폴더가 존재하지 않습니다.\n" + fail_List_exist + "번째 항목이 변경되지 않았습니다.\n" + fail_Count_file + "개의 중복된 파일명이 존재합니다.\n" + fail_List_file + "번째 항목이 변경되지 않았습니다.\n" + fail_Count_folder + "개의 중복된 폴더명이 존재합니다.\n" + fail_List_folder + "번째 항목이 변경되지 않았습니다."); } else if (fail_Count_exist > 0 && fail_Count_file > 0) { MessageBox.Show(fail_Count_exist + "개의 파일 또는 폴더가 존재하지 않습니다.\n" + fail_List_exist + "번째 항목이 변경되지 않았습니다.\n" + fail_Count_file + "개의 중복된 파일명이 존재합니다.\n" + fail_List_file + "번째 항목이 변경되지 않았습니다."); } else if (fail_Count_exist > 0 && fail_Count_folder > 0) { MessageBox.Show(fail_Count_exist + "개의 파일 또는 폴더가 존재하지 않습니다.\n" + fail_List_exist + "번째 항목이 변경되지 않았습니다.\n" + fail_Count_folder + "개의 중복된 폴더명이 존재합니다.\n" + fail_List_folder + "번째 항목이 변경되지 않았습니다."); } else if (fail_Count_file > 0 && fail_Count_folder > 0) { MessageBox.Show(fail_Count_file + "개의 중복된 파일명이 존재합니다.\n" + fail_List_file + "번째 항목이 변경되지 않았습니다.\n" + fail_Count_folder + "개의 중복된 폴더명이 존재합니다.\n" + fail_List_folder + "번째 항목이 변경되지 않았습니다."); } else if (fail_Count_exist > 0) { MessageBox.Show(fail_Count_exist + "개의 파일 또는 폴더가 존재하지 않습니다.\n" + fail_List_exist + "번째 항목이 변경되지 않았습니다.\n"); } else if (fail_Count_file > 0) { MessageBox.Show(fail_Count_file + "개의 중복된 파일명이 존재합니다.\n" + fail_List_file + "번째 항목이 변경되지 않았습니다.\n"); } else if (fail_Count_folder > 0) { MessageBox.Show(fail_Count_folder + "개의 중복된 폴더명이 존재합니다.\n" + fail_List_folder + "번째 항목이 변경되지 않았습니다."); } if (fail_Count_Length > 0) { MessageBox.Show(fail_Count_Length + "개의 항목 이름이 너무 깁니다.\n" + fail_List_Length + "번째 항목이 변경되지 않았습니다."); } if (fail_Count_ZeroLength > 0) { MessageBox.Show(fail_Count_ZeroLength + "개의 항목의 변경할 이름이 없습니다.\n" + fail_List_ZeroLength + "번째 항목이 변경되지 않았습니다."); } width_Resize();//너비 재조정 }