我怎样才能得到文件的扩展名 [英] How Can I Get The Extension Of File

查看:73
本文介绍了我怎样才能得到文件的扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取文件的扩展名

解决方案

 FileInfo f =  new  FileInfo(  pathtofile.txt); 
string ext = f.Extension; // 返回txt


 使用 System.IO; 

...

Dim fileName As 字符串 = C:\ mydir.old \ myfile.ext
Dim extension As 字符串

extension = Path.GetExtension(fileName)





参见 Path.GetExtension Method [ ^ ]


how can i get the extension of file

解决方案

FileInfo f = new FileInfo("pathtofile.txt");
string ext = f.Extension; //returns txt


using System.IO;

...

Dim fileName As String = "C:\mydir.old\myfile.ext"
Dim extension As String

extension = Path.GetExtension(fileName)



See Path.GetExtension Method[^]


这篇关于我怎样才能得到文件的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆