using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace FilePathAndFileName
{
///
/// Form1에 대한 요약 설명입니다.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtFile;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox txtDir;
public string strDir;
public string strFileType;
private System.Windows.Forms.Label lblFileCount;
///
/// 필수 디자이너 변수입니다.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows Form 디자이너 지원에 필요합니다.
//
InitializeComponent();
//
// TODO: InitializeComponent를 호출한 다음 생성자 코드를 추가합니다.
//
}
///
/// 사용 중인 모든 리소스를 정리합니다.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// 디자이너 지원에 필요한 메서드입니다.
/// 이 메서드의 내용을 코드 편집기로 수정하지 마십시오.
///
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.txtFile = new System.Windows.Forms.TextBox();
this.btnSearch = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.txtDir = new System.Windows.Forms.TextBox();
this.lblFileCount = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(920, 456);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "검색할 폴더를 입력해 주세요";
//
// groupBox1
//
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnSave,
this.btnSearch,
this.txtFile,
this.label1});
this.groupBox1.Location = new System.Drawing.Point(624, 472);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(288, 40);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "파일 검색";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 17);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(42, 14);
this.label1.TabIndex = 0;
this.label1.Text = "확장자";
//
// txtFile
//
this.txtFile.Location = new System.Drawing.Point(72, 11);
this.txtFile.Name = "txtFile";
this.txtFile.Size = new System.Drawing.Size(65, 21);
this.txtFile.TabIndex = 1;
this.txtFile.Text = "asp";
this.txtFile.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// btnSearch
//
this.btnSearch.Location = new System.Drawing.Point(144, 11);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(65, 24);
this.btnSearch.TabIndex = 2;
this.btnSearch.Text = "검 색";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(224, 11);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(49, 24);
this.btnSave.TabIndex = 3;
this.btnSave.Text = "닫 기";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// groupBox2
//
this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.txtDir});
this.groupBox2.Location = new System.Drawing.Point(408, 472);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(200, 40);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "검색할 폴더";
//
// txtDir
//
this.txtDir.Location = new System.Drawing.Point(8, 12);
this.txtDir.Name = "txtDir";
this.txtDir.Size = new System.Drawing.Size(184, 21);
this.txtDir.TabIndex = 0;
this.txtDir.Text = "";
//
// lblFileCount
//
this.lblFileCount.AutoSize = true;
this.lblFileCount.Location = new System.Drawing.Point(280, 488);
this.lblFileCount.Name = "lblFileCount";
this.lblFileCount.Size = new System.Drawing.Size(73, 14);
this.lblFileCount.TabIndex = 3;
this.lblFileCount.Text = "파일개수 : 0";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(920, 525);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblFileCount,
this.groupBox2,
this.groupBox1,
this.richTextBox1});
this.Name = "Form1";
this.Text = "Form1";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// 해당 응용 프로그램의 주 진입점입니다.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
strDir = this.txtDir.Text;
strFileType = this.txtFile.Text;
if(strDir=="")
{
MessageBox.Show("검색할 폴더를 입력하게~~~!");
return;
}
if(strFileType=="")
{
MessageBox.Show("검색할 파일 확장자를 입력하게....! 훼훼");
return;
}
this.richTextBox1.Text="";
printDoc(strDir);
this.lblFileCount.Text = this.richTextBox1.Lines.Length.ToString();
}
private void printDoc(string LoadPath)
{
DirectoryInfo dir = new DirectoryInfo(LoadPath);
DirectoryInfo[] subDirs = dir.GetDirectories();
FileInfo[] subFiles = dir.GetFiles();
foreach(FileInfo f in subFiles)
{
if(f.LastWriteTime.ToShortDateString()=="2004-11-13")
{
this.richTextBox1.Text += LoadPath + ", " + f.Name + "\n";
}
if(f.CreationTime.ToShortDateString()=="2004-11-13"){
this.richTextBox1.Text += LoadPath + ", " + f.Name + "\n";
}
/*
if(f.Extension=="." + strFileType.ToLower())
{
this.richTextBox1.Text += LoadPath + ", " + f.Name + "\n";
}
*/
}
foreach(DirectoryInfo d in subDirs)
{
printDoc(d.FullName);
}
}
private void btnSave_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}