c#对话框

 OpenFileDialog open = new OpenFileDialog();//创建对话框
            open.InitialDirectory = @"C:Documents and SettingsAll Users桌面"; //设置对话框路径
            open.Title = "对话框1"; //对话框标题
            open.Filter = "文本文档|*.txt|所有文件|*.*";
            open.Multiselect = true; //多选
            open.ShowDialog(); //打开对话框
            //string[] paths = open.FileName;
            string paths = open.FileName;  //读取文件的全路径
            if (paths == "") return;
            using (FileStream file = new FileStream(paths, FileMode.OpenOrCreate, FileAccess.Read)) 
            {
                byte[] bytes = new byte[1024 * 1024 * 5];
                int r = file.Read(bytes, 0, bytes.Length);
                this.textBox1.Text = Encoding.Default.GetString(bytes, 0, r);
            }

  

 int temp=0;
            int[] a = { 23, 44, 66, 76, 98, 11, 3, 9, 7 };
            for (int i = 0; i < a.Length; i++) 
            {
                for (int j = 0; j < a.Length-i-1; j++) 
                {
                    if (a[j] < a[j + 1])  //从大到小
                    {
                        temp=a[j];
                        a[j]=a[j+1];
                        a[j+1]=temp;
                    }
                }
               
            }
            Console.WriteLine("排序后的数组:");
            foreach (int item in a)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();
            Console.ReadKey();

  

SaveFileDialog sd=new SaveFileDialog(); //创建
            // 保存文件对话框
            sd.InitialDirectory = @"C:Documents and SettingsAll Users桌面"; //设置对话框路径
            sd.Title = "对话框1"; //对话框标题
            sd.Filter = "文本文档|*.txt|所有文件|*.*";
            sd.ShowDialog();
            string path = sd.FileName;
            using (FileStream fsv = new FileStream(path, FileMode.Create, FileAccess.Write)) 
            {
                byte[] bytes = Encoding.Default.GetBytes(this.textBox1.Text);
                fsv.Write(bytes, 0, bytes.Length);
            }

  

 private void button3_Click(object sender, EventArgs e)
        {
            FontDialog fonts = new FontDialog();
         
            fonts.ShowDialog();
            this.textBox1.Font = fonts.Font;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            ColorDialog color = new ColorDialog();
            color.ShowDialog();
            this.textBox1.BackColor = color.Color;
            this.textBox1.ForeColor = color.Color;
        }

  

原文地址:https://www.cnblogs.com/mengluo/p/5476544.html