我怎样才能只读取文件名 [英] How can I read just the name of the file

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

问题描述

当我放

fileName=openFileDialog.FileName 

时,我得到了完整的路径,但我只是
需要文件名.

解决方案

要获取文件名,请使用Path.GetFileName(fileName)


fileName=openFileDialog.SafeFileName 


这应该可以帮助您:

 字符串 theFileName = System.IO.Path.GetFileName(fileName); 


When I put

fileName=openFileDialog.FileName 

I get the full path, but I just
want the name of the file.

解决方案

To get the filename, use Path.GetFileName(fileName)


fileName=openFileDialog.SafeFileName 


This should help you:

String theFileName = System.IO.Path.GetFileName(fileName);


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

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