none
ekdmackwrl RRS feed

  • 질문

  • namespace 찾기
    {
        public partial class Form2 : Form
        {
            public Form1 dlg;

            int StartP = 0;
           
            public Form2(Form1 a)
            {
                InitializeComponent();
                dlg = a;
            }

            private void button1_Click(object sender, EventArgs e)
            {
                string str = dlg.textBox1.Text;

                if (str.Contains(textBox1.Text))
                {
                    int i = str.IndexOf(textBox1.Text, 0);

                    if (i != -1)
                    {
                        int j = textBox1.Text.Length;

                        str = str.Remove(i, j);
                        str = str.Insert(i, textBox2.Text);
                        dlg.textBox1.Text = str;
                    }
                }
            }

            private void button4_Click(object sender, EventArgs e)
            {
                this.Close();
            }

            private void button3_Click(object sender, EventArgs e)
            {
                string str = dlg.textBox1.Text;
                if (str.Contains(textBox1.Text))
                {
                    str = str.Replace(textBox1.Text, textBox2.Text);
                    dlg.textBox1.Text = str;
                }
               
            }

            private void button2_Click(object sender, EventArgs e)
            {
                string str = dlg.textBox1.Text;
                if(str.Contains(textBox1.Text))
                {
                    StartP = str.IndexOf(textBox1.Text, StartP);

                    if (StartP != -1)
                    {
                        int b = textBox1.Text.Length;
                        dlg.textBox1.Select(StartP, b);
                        dlg.textBox1.Focus();
                        StartP++;
                    }

                    else
                    {
                        MessageBox.Show("찾을 문자가없습니다");
                        StartP = 0;
                    }
                }
              
            }
        }
    }

    ---------------------------------------------------
    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace 파일탐색기
    {
        public partial class Form1 : Form
        {
            public DirectoryInfo dinfo;
            public DirectoryInfo[] dir;
            public int count;
            ArrayList ar=new ArrayList();
            string adress;      
     
            public Form1()
            {
                InitializeComponent();
                count = 0;
            }
            public void make_list()
            {

                listView1.Items.Clear();

                ListViewItem item = new ListViewItem("..");
                item.SubItems.Add("");
                item.SubItems.Add("");
                item.SubItems.Add("");
                listView1.Items.Add(item);
                dir = dinfo.GetDirectories();
                count = dir.Length + 1;
                foreach (DirectoryInfo d in dir)
                {
                    ListViewItem item1 = new ListViewItem(d.Name.ToString(), 0);
                    item1.SubItems.Add(d.Attributes.ToString());
                    item1.SubItems.Add("");
                    item1.SubItems.Add(d.CreationTime.ToString());
                    listView1.Items.Add(item1);
                }
                FileInfo[] file = dinfo.GetFiles();
                foreach (FileInfo f in file)
                {
                    ListViewItem item2 = new ListViewItem(f.Name.ToString(), 1);
                    item2.SubItems.Add(f.Attributes.ToString());
                    item2.SubItems.Add(f.Length.ToString());
                    item2.SubItems.Add(f.CreationTime.ToString());
                    listView1.Items.Add(item2);
                }
                Text = dinfo.FullName.ToString();
               
            }


            private void 열기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                openFileDialog1.ShowDialog();
                dinfo = new DirectoryInfo(openFileDialog1.FileName);
                dinfo = dinfo.Parent;

                make_list();
            }

            private void listView1_Click(object sender, EventArgs e)
            {
                int index = listView1.FocusedItem.Index;
                if (index >= count)
                {
                   
                    return;
                }
                else if (index != 0)
                    dinfo = dir[index - 1];
                else
                {
                    if (dinfo.Parent == null)
                    {
                        MessageBox.Show("루트디렉토리입니다.");
                        return;
                    }
                   
                    dinfo = dinfo.Parent;
                }
                make_list();  
            }

            private void 파일복사하기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                FileInfo[] file = dinfo.GetFiles();
                ar.Clear();
               
                for(int i=0;i<listView1.SelectedItems.Count;i++)
                {
                    foreach (FileInfo f in file)
                    {
                        if(listView1.SelectedItems[i].Text==f.Name)
                        {
                            adress = f.FullName.ToString();
                            ar.Add(f.Name.ToString());                       
                        }
                    }
                }   
            }

            private void 붙이기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                FileInfo[] file = dinfo.GetFiles();
                string w = @"\";
                int copy_count = 0;
                foreach (string s in ar)
                {
                    for (int i = 0; i < file.Length; i++)
                    {
                        if (file[i].Name == s)
                        {
                            copy_count++;
                            MessageBox.Show(s+" 파일은 이미 존재합니다.");
                        }
                    }
                    if (copy_count == 0)
                    {
                        File.Copy(@adress, @Text + w + s);
                    }                   
                }
                listView1.Items.Clear();
                make_list();           
            }

            private void 파일삭제ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                FileInfo[] file = dinfo.GetFiles();
               
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    foreach (FileInfo f in file)
                    {
                        if (listView1.SelectedItems[i].Text == f.Name)
                        {
                            f.Delete();
                           
                        }
                    }
                }
                listView1.Items.Clear();
                make_list(); 
            }

            private void 끝내기ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Close();
            }
        }

    }

    2009년 10월 14일 수요일 오전 3:24

모든 응답