zoukankan      html  css  js  c++  java
  • 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;
            }
    

      

  • 相关阅读:
    dpkg安装deb缺少依赖包的解决方法
    一个linux命令之grep---1
    win10快捷键
    Windows Server 2008 R2遗忘管理员密码后的解决方案
    手工释放linux内存
    oracle数据库用户加锁和解锁
    完全卸载Oracle数据库软件
    Linux上VNC 启动和关闭常见问题
    Linux 开启VNCSERVER
    RedHat 简易配置 VNC Server 与VNC View详细说明
  • 原文地址:https://www.cnblogs.com/mengluo/p/5476544.html
Copyright © 2011-2022 走看看