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;
            }
    

      

  • 相关阅读:
    CentOS ping www.baidu.com 报错 name or service not know
    python2 当中 遇到 UnicodeDecodeError UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 37: ordinal not in range(128)
    shell基本语法
    android---笔记 AppContext extends Application
    android笔记--加载框
    android笔记--与服务器交互更改简历状态
    android笔记---AndroidManifest.xml
    android笔记-----消息提示
    ios笔记一 追加数据
    android笔记一 控件属性
  • 原文地址:https://www.cnblogs.com/mengluo/p/5476544.html
Copyright © 2011-2022 走看看