首页 > Windows开发 > 详细

C# 可视化读取文件

时间:2016-04-24 21:45:14      阅读:234      评论:0      收藏:0      [点我收藏+]
OpenFileDialog fd = new OpenFileDialog();
            fd.Filter = "txt files (*.txt)|*.txt|All files(*.*)|*.*";
            fd.InitialDirectory = Application.StartupPath + "\\Temp\\";
            fd.ShowReadOnly = true;
            DialogResult r = fd.ShowDialog();
            if(r == DialogResult.OK)
            {
                string all = fd.FileName;
                string path = all.Substring(0, all.LastIndexOf("\\") + 1);
                string fileName = all.Substring(all.LastIndexOf("\\") + 1, all.LastIndexOf(".") - (all.LastIndexOf("\\") + 1));
                string fileExc = all.Substring(all.LastIndexOf(".") + 1, all.Length - all.LastIndexOf(".") - 1);

                System.Console.WriteLine("all = {0}", all);
                System.Console.WriteLine("path = {0}" ,path);
                System.Console.WriteLine("fileName = {0}", fileName);
                System.Console.WriteLine("fileExc = {0}",fileExc);
            }

 

C# 可视化读取文件

原文:http://www.cnblogs.com/ficow/p/5428264.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!