闪电龟龟--笔记

万物寻其根,通其堵,便能解其困。
  博客园  :: 新随笔  :: 管理

Winform中获取文件的路径

Posted on 2019-09-05 20:55  闪电龟龟  阅读(703)  评论(0编辑  收藏  举报

winform中获取文件路径(注:下面这些方式需要放在根目录下,否则获取失败)

// 配置文件的目录
        //protected string Root = System.Windows.Forms.Application.StartupPath;  // 获取启动文件的信息,如:E:\C#Code\Sharing\Sharing\bin\Debug,等价于System.Environment.CurrentDirectory;和 System.IO.Directory.GetCurrentDirectory()
        //protected string _ExeRoot = System.Windows.Forms.Application.ExecutablePath;  // 获取启动文件的信息,如:E:\C#Code\Sharing\Sharing\bin\Debug\Sharping.exe

// 获取父类路径