码迷,mamicode.com
首页 > Windows程序 > 详细

C# 可视化读取文件

时间:2016-04-24 21:45:28      阅读:268      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!