/// <summary> /// 선택한 폴더 리스트 추가 /// </summary> /// <param name="folderName"></param> public void AddRandomVideoFolderList(string folderPath) { int videoCount = CountFolderVideos(folderPath); try { if (RandomVideoFolderListView.Items.Count == 0) { RandomFolder randomFolder = new RandomFolder(folderPath, Path.GetFileName(folderPath)); randomFolderList.Add(randomFolder); ListViewItem listViewItem = new ListViewItem(randomFolder.folderName); listViewItem.SubItems.Add(videoCount.ToString() + "개"); RandomVideoFolderListView.Items.Add(listViewItem); log.SaveListLog(randomFolderList, PathList.randomVideoFolderLists, PathList.randomPath); log.WriteLog(folderName + " 추가"); } else { bool isName = true; // 리스트 중복 체크 for (int i = 0; i < RandomVideoFolderListView.Items.Count; i++) { ListViewItem listViewItem = RandomVideoFolderListView.Items[i]; if (listViewItem.SubItems[0].Text.Contains(Path.GetFileName(folderPath))) { isName = false; } } if (isName) { RandomFolder randomFolder = new RandomFolder(folderPath, Path.GetFileName(folderPath)); randomFolderList.Add(randomFolder); ListViewItem listViewItem = new ListViewItem(Path.GetFileName(folderPath)); listViewItem.SubItems.Add(videoCount.ToString() + "개"); RandomVideoFolderListView.Items.Add(listViewItem); log.SaveListLog(randomFolderList, PathList.randomVideoFolderLists, PathList.randomPath); log.WriteLog(folderName + " 추가"); } } } catch (Exception e) { MessageBox.Show("[에러발생] 관리자에게 문의하세요"); log.WriteLog("[Error] : " + e); } }
/// <summary> /// 텍스트 파일에서 리스트 저장 기록 가져와서 List에 저장 /// </summary> public void GetListLogMessage() { log.WriteLog("리스트 가져오기"); try { using (StreamReader streamReader = new StreamReader(PathList.randomPath + PathList.randomVideoFolderLists)) { string listLogMessage = string.Empty; while ((listLogMessage = streamReader.ReadLine()) != null) { string[] folderArray = listLogMessage.Split(','); DirectoryInfo directoryInfo = new DirectoryInfo(folderArray[0]); if (directoryInfo.Exists) { RandomFolder randomFolder = new RandomFolder(folderArray[0], folderArray[1]); randomFolderList.Add(randomFolder); } else { MessageBox.Show(folderArray[1] + " 폴더가 존재하지 않습니다. 경로를 다시 확인해주세요."); } } } } catch (Exception e) { MessageBox.Show("[에러발생] 리스트 가져오기에 실패했습니다. 로그파일을 확인해주세요."); log.WriteLog("[Error] : 리스트 가져오기 실패\n" + e); } finally { log.WriteLog("리스트 가져오기 성공"); } UpdateRandomListView(); }