分离文件路径_名称和扩展名源代码

   2023-03-12 22:42:12 8080
核心提示:分离文件路径、名称和扩展名源代码:程序界面using System;using System.Collections.Generic;using System.ComponentModel;using

分离文件路径_名称和扩展名源代码

分离文件路径、名称和扩展名源代码:

程序界面

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //"E:studymydatabase学生个人数据库.accdb" if (openFileDialog1.ShowDialog()==DialogResult.OK) { string f_all = openFileDialog1.FileName; string f_path = f_all.Substring(0, f_all.LastIndexOf("") + 1); string f_name = f_all.Substring(f_all.LastIndexOf("") + 1, f_all.LastIndexOf(".") - (f_all.LastIndexOf("") + 1)); string f_ex = f_all.Substring(f_all.LastIndexOf(".") + 1, f_all.Length - (f_all.LastIndexOf(".") + 1)); label1.Text = "文件路径:" + f_path; label2.Text = "文件名:" + f_name; label3.Text = "扩展名:" + f_ex; } } }}结语:学会使用打开对话框控件openFileDialog和截取字符串方法Substring和获取特定字符索引号IndexOf(正序)和LastIndexOf(倒序),喜欢得请感谢对创作者的支持收藏!

 
举报收藏 0打赏 0评论 0
 
更多>同类百科头条
推荐图文
推荐百科头条
最新发布
点击排行
推荐产品
网站首页  |  公司简介  |  意见建议  |  法律申明  |  隐私政策  |  广告投放  |  如何免费信息发布?  |  如何开通福步贸易网VIP?  |  VIP会员能享受到什么服务?  |  怎样让客户第一时间找到您的商铺?  |  如何推荐产品到自己商铺的首页?  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  粤ICP备15082249号-2