如何 获得 文件名 的 后缀名?????????????? 急!!!!!!!!

fsqman 2006-04-28 05:30:41
如何 获得 文件名 的 后缀名?????????????? 急!!!!!!!!

例如 获到的 文件名是 "aaa.doc" , 我想得到文件后缀名 , 返回 "doc" ,


例如 获到的 文件名是 "aaa.dd.pdf" , 我想得到文件后缀名 , 返回 "pdf"

如何实现???
...全文
313 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
copico 2006-04-29
  • 打赏
  • 举报
回复
Dim f As New IO.FileInfo("d:\123")
Dim StrExe As String = f.Extension
Ninputer 2006-04-29
  • 打赏
  • 举报
回复
怎么还有回答用Split的,真是……
sz_lgp 2006-04-29
  • 打赏
  • 举报
回复
dim str1 as string()
str1=str_x.split(".")

后缀=str1(1)
HAVENT 2006-04-29
  • 打赏
  • 举报
回复
Dim str As String
str = str.Substring(str.LastIndexOf("."), str.Length)
Ninputer 2006-04-29
  • 打赏
  • 举报
回复
用这个吧……
System.IO.Path.GetExtesion()
楼上们都写了,你不看,非要Split
fsqman 2006-04-29
  • 打赏
  • 举报
回复
Dim str As String
str="aa.doc"
str = str.Substring(str.LastIndexOf("."), str.Length)

试过,但出错!!!!
singlepine 2006-04-28
  • 打赏
  • 举报
回复
string path=@"c:\test\a.txt";

string ChangeExtension=System.IO.Path.ChangeExtension(path,".old");//更改路径字符串的扩展名。
string CombinePath=System.IO.Path.Combine(@"c:\","b.txt");//合并两个路径字符串。
string DirectoryName=System.IO.Path.GetDirectoryName(path);//返回指定路径字符串的目录信息。
string Extension=System.IO.Path.GetExtension(path);//返回指定的路径字符串的扩展名。
string FileName=System.IO.Path.GetFileName(path);//返回指定路径字符串的文件名和扩展名。
string FileNameWithoutExtension=System.IO.Path.GetFileNameWithoutExtension(path); //返回不具有扩展名的指定路径字符串的文件名。
string FullPath=System.IO.Path.GetFullPath(path);//返回指定路径字符串的绝对路径。
string PathRoot=System.IO.Path.GetPathRoot(path);//获取指定路径的根目录信息。
string TempFileName=System.IO.Path.GetTempFileName();//返回唯一临时文件名并在磁盘上通过该名称创建零字节文件。
string TempPath=System.IO.Path.GetTempPath();//返回当前系统的临时文件夹的路径。
string HasExtension=System.IO.Path.HasExtension(path).ToString();//确定路径是否包括文件扩展名。
string IsPathRooted=System.IO.Path.IsPathRooted(path).ToString();//获取一个值,该值指示指定的路径字符串是包含绝对路径信息还是包含相对路径信息。
CBryan 2006-04-28
  • 打赏
  • 举报
回复
yurow(夕阳轨迹) 正解
cushat 2006-04-28
  • 打赏
  • 举报
回复
看System.IO.Path的参考
yurow 2006-04-28
  • 打赏
  • 举报
回复
Dim a,b As String //文件名
b = a.Substring(a.LastIndexOf("."), a.Length) //结果
kssys 2006-04-28
  • 打赏
  • 举报
回复
啊?这不是文字处理吗?
foyuan 2006-04-28
  • 打赏
  • 举报
回复
System.IO.Path.GetExtesion()
可能名称写错了
你看VS提示就行了 呵呵
cancerser 2006-04-28
  • 打赏
  • 举报
回复
方法1:自己分('.')
方法2:File 或FileInfo 类中有取扩展名的方法

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧