Пример #1
0
        private void SearchFile(string searchPath)
        {
            if (File.Exists(searchPath))
            {
                try
                {
                    FileInfo item = new FileInfo(searchPath);

                    ListViewFileList.BeginUpdate();
                    if (item.Attributes == FileAttributes.System)
                    {
                        ListViewFileList.EndUpdate();
                        return;
                    }
                    if (IsExist(item))
                    {
                        string fileType      = GetFileType(Extension.CheckExtensionType(item.Extension.Substring(1, item.Extension.Length - 1)));
                        string fileName      = GetPureFileName(item.Name);
                        string fileSize      = item.Length.ToString();
                        string directoryName = item.DirectoryName;
                        string accessTime    = item.LastAccessTime.ToString();

                        fileSize = (Double.Parse(fileSize) / 1024.0).ToString("0.#");
                        ListViewItem tmp = new ListViewItem(new String[] { fileType, fileName, directoryName, accessTime, fileSize });
                        this.ListViewFileList.Items.Add(tmp);
                    }
                }
                catch (UnauthorizedAccessException e)
                {
                    MessageBox.Show(e.Message);
                }
            }
            ListViewFileList.EndUpdate();
        }
Пример #2
0
 /// <summary>
 /// 새로고침	, 이 부분은 조금 고민해봐야 함
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonRefresh_Click(object sender, EventArgs e)
 {
     ListViewFileList.BeginUpdate();
     ListViewFileList.Items.Clear();
     ApplyAllFiles(MainForm.pTextPath.Text, SearchFile);
     ListViewFileList.EndUpdate();
 }
Пример #3
0
        /// <summary>
        /// 삭제
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonDeleteSelect_Click(object sender, EventArgs e)
        {
            int i = 0;

            ListView.SelectedListViewItemCollection selectedItems = ListViewFileList.SelectedItems;
            ListView.SelectedIndexCollection        items         = ListViewFileList.SelectedIndices;

            while (items.Count > 0)
            {
                string   remove     = selectedItems[i].SubItems[1].Text + @"\" + selectedItems[i].Text;
                FileInfo removeFile = new FileInfo(remove);
                if (removeFile.Exists)
                {
                    removeFile.Delete();
                }
                ListViewFileList.Items[i].Remove();
            }
            ListViewFileList.Refresh();
        }
Пример #4
0
        /// <summary>
        /// 일괄 이동
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonMove_Click(object sender, EventArgs e)
        {
            int i = 0;
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            dialog.ShowDialog();
            movePath = dialog.SelectedPath;

            ListView.SelectedListViewItemCollection selectedItems = ListViewFileList.SelectedItems;
            ListView.SelectedIndexCollection        items         = ListViewFileList.SelectedIndices;

            while (i < items.Count && movePath.Equals("") == false)
            {
                string   move     = selectedItems[i].SubItems[2].Text + @"\" + selectedItems[i].SubItems[1].Text;
                FileInfo moveFile = new FileInfo(move);
                if (moveFile.Exists)
                {
                    try
                    {
                        moveFile.MoveTo(movePath + @"\" + selectedItems[i].SubItems[1].Text);
                        ListViewFileList.Items[i].SubItems[2].Text = movePath;
                    }
                    catch
                    {
                        // 중복 시, 상위 폴더 명을 접합
                        string tmp = CreateAdditionalString(selectedItems[i].SubItems[2].Text);
                        moveFile.MoveTo(movePath + @"\" + tmp + selectedItems[i].SubItems[1].Text);
                        ListViewFileList.Items[i].SubItems[1].Text = tmp + selectedItems[i].SubItems[1].Text;
                        ListViewFileList.Items[i].SubItems[2].Text = movePath;
                    }
                    finally
                    {
                        if (movePath.Contains(MainForm.pTextPath.Text) == false)
                        {
                            ListViewFileList.Items[i].Remove();
                            ListViewFileList.Refresh();
                        }
                    }
                }
                i++;
            }
        }
Пример #5
0
 /// <summary>
 /// 폼 닫히는 경우 업데이트 종료
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Search_FormClosed(object sender, FormClosedEventArgs e)
 {
     ListViewFileList.EndUpdate();
 }