示例#1
0
        /// <summary>
        /// フォルダを再帰的に探索していく
        /// </summary>
        /// <param name="p_strRootPath"></param>
        /// <param name="p_lstFileInfos"></param>
        /// <returns></returns>
        private FileInfo[] GetList(string p_strRootPath, List <FileInfo> p_lstFileInfos = null)

        {
            bool bFind = false;

            if (p_lstFileInfos == null)
            {
                p_lstFileInfos = new List <FileInfo>();
            }
            if (!Cancel)
            {
                // 検索中の情報を外部に伝える
                NowPath = p_strRootPath;
                //m_lstFolder.Add(root);
                try
                {
                    // ファイル検索
                    if (m_nType == 0 || m_nType == 2)
                    {
                        foreach (string strFilePath in Directory.GetFiles(p_strRootPath, m_strFilePattern))
                        {
                            bFind = true;
                            p_lstFileInfos.Add(new FileInfo(strFilePath, false));
                        }
                    }

                    // フォルダ検索
                    if (m_nType == 1 || m_nType == 2)
                    {
                        foreach (string strFolderPath in Directory.GetDirectories(p_strRootPath, m_strFilePattern))
                        {
                            p_lstFileInfos.Add(new FileInfo(strFolderPath, true));
                            m_lstFolder.Add(new DirInfo(strFolderPath, true));
                        }
                    }
                    if (bFind)
                    {
                        DirInfo info = new DirInfo(p_strRootPath, false);
                        if (!m_lstFolder.Contains(info))
                        {
                            m_lstFolder.Add(info);
                        }
                    }
                    if (m_bSub)
                    {
                        // サブフォルダを検索する
                        foreach (string strSubFolderPath in Directory.GetDirectories(p_strRootPath))
                        {
                            string dis = Path.Combine(p_strRootPath, strSubFolderPath);
                            GetList(dis, p_lstFileInfos);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionMsg += ex.Message + "\r\n";
                }
                m_bgwWk1.ReportProgress(p_lstFileInfos.Count);
            }
            return(p_lstFileInfos.ToArray());
        }
示例#2
0
 /// <summary>
 /// 構造体と比較
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(DirInfo other)
 {
     return(other.strPath == strPath);
 }
示例#3
0
        // ファイル検索完了後処理
        private void Bgw_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            string strCancelMsg = "結果";

            pWait.Visible = false;

            if (m_objFS.ExceptionMsg != "")
            {
                btnError.Visible = true;

                //MessageBox.Show("実行中エラーが発生しました\n" + m_FS.ExeptionMsg);
            }

            if (!e.Cancelled)
            {
                m_nSort = 0;
                // 検索対象が、どちらか一方の時は、名前のみソート
                if (rdoSearch.SelectedIndex != 2)
                {
                    m_nSortMax = 2;
                }
                // 両方の時は、種類順のソート
                else
                {
                    m_nSortMax = 4;
                }

                try
                {
                    //trvDir.AddNode(strROOT,3,3);

                    DebugWrite("Start");
                    trvDir.Visible = false;
                    trvDir.SuspendLayout();
                    Refresh();
                    TreeNodeElements[] aryNodeElm = new TreeNodeElements[m_objFS.FolderResult.Count];
                    for (int nCnt = 0; nCnt < m_objFS.FolderResult.Count; nCnt++)
                    {
                        DirInfo objDirInfo = m_objFS.FolderResult[nCnt];
                        string  strRefPath = objDirInfo.strPath.Replace(cmbRoot.ComboText, strROOT);
                        aryNodeElm[nCnt] = new TreeNodeElements(strRefPath, 0, 2,
                                                                (objDirInfo.bIsSeach) ? Color.Blue : SystemColors.ControlText);
                    }
                    prgTreeCreate.Maximum = aryNodeElm.Length;
                    trvDir.AddNodeRange(aryNodeElm);

                    /*
                     * // フォルダツリーを作成
                     * foreach(DirInfo dirInfo in m_objFS.FolderResult)
                     * {
                     *      string strRefPath = dirInfo.strPath.Replace(cmbRoot.ComboText, strROOT);
                     *      TreeNode node= trvDir.AddNode(strRefPath, 0, 2);
                     *      if (dirInfo.bIsSeach)
                     *      {
                     *              node.ForeColor = Color.Blue;
                     *      }
                     * }
                     * trvDir.ResumeLayout();
                     * trvDir.Visible = true;
                     *
                     * trvDir.SelectedNode = trvDir.FindNode(strROOT);
                     * trvDir.Select();
                     * DebugWrite("End");
                     */
                }
                catch (Exception exp1)
                {
                    MessageBox.Show(exp1.Message);
                }
                this.Refresh();
                SortProc();
            }
            else
            {
                strCancelMsg = "[中断]";
            }

            searching.Text = "";
            Cursor.Current = Cursors.Default;
            // ボタンの表示と動作を元に戻す。
            btnClip.Enabled       = true;
            pnl.Enabled           = true;
            btnSearch.Text        = "検索";
            btnSearch.Enabled     = true;
            cmbRoot.FIllBoxEnable = true;
            stat           = ProcState.Default;
            lblResult.Text = string.Format("検索{0} {1:#,0}件", strCancelMsg, m_objFS.FileResult.Count);
        }