⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 C#开发教程 由浅入深 配有实例 是初学者的好帮手
💻 CS
字号:
using System;
using System.IO;
using System.Windows.Forms;

namespace FileDialog
{
    class FileDialogApp
    {
        private static OpenFileDialog ofd;

        [STAThread]
        static void Main(string[] args)
        {
            ofd = new OpenFileDialog();
            string s = Path.GetDirectoryName(
                Path.GetDirectoryName(
                Directory.GetCurrentDirectory()));
            
            ofd.InitialDirectory = s;
            ofd.FileOk += 
                new System.ComponentModel.CancelEventHandler(
                ofd_OK);
            ofd.ShowDialog();
        }
        public static void ofd_OK (object sender, 
            System.ComponentModel.CancelEventArgs e)
        {
            StreamReader sr = new StreamReader(ofd.FileName);
            string s;
            while ((s = sr.ReadLine()) != null)
            {
                Console.WriteLine(s);
            }
            sr.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -