获取图像名称而不显示其扩展名 [英] Get name of an image without displaying its extension

查看:97
本文介绍了获取图像名称而不显示其扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家晚上好,

如何检索不带扩展名的图像名称?

Good evening all,

How to retrieve the name of an image without the extension??

for (int i = 0; i<tab.length;>
{
     string ImageName = tab[i].TextureFilename;
     Console.WriteLine(i + "____" + ImageName);
}



谢谢!!!!



Thank you!!!!

推荐答案

首先,文件名是简单的字符串操作.您只需获取最后一个"的位置即可.字符,然后从此删除所有内容.

或者,您可以将文件名传递给 Path.GetFileNameWithoutExtension [ ^ ]方法
First, the filename is simple string manipulation. You can just get the position of the last "." character, then remove everything from that point on.

Or, you can just pass the filename to the Path.GetFileNameWithoutExtension[^] method.


一种方法是在名称中找到点的位置,然后从该点开始剥离所有内容.

另一种方式可能是,如果您知道扩展名是什么,您可以做ImageName.Replace(".ext", "");

尝试搜索字符串处理例程.你知道.在Google中.您可以在其中搜索内容的网站.
One way would be to find the position of the dot in the name and strip off everything from that point on.

Another way might be if you knew what the extension was you could do ImageName.Replace(".ext", "");

Try searching on string handling routines. You know. In Google. That site where you can search for stuff.


这篇关于获取图像名称而不显示其扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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