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

      

  • 相关阅读:
    bzoj2733 永无乡 平衡树按秩合并
    bzoj2752 高速公路 线段树
    bzoj1052 覆盖问题 二分答案 dfs
    bzoj1584 打扫卫生 dp
    bzoj1854 游戏 二分图
    bzoj3316 JC loves Mkk 二分答案 单调队列
    bzoj3643 Phi的反函数 数学 搜索
    有一种恐怖,叫大爆搜
    BZOJ3566 概率充电器 概率dp
    一些奇奇怪怪的过题思路
  • 原文地址:https://www.cnblogs.com/mengluo/p/5476544.html
Copyright © 2011-2022 走看看