Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good evening all,

How to retrieve the name of an image without the extension??
C#
for (int i = 0; i<tab.length;>
{
     string ImageName = tab[i].TextureFilename;
     Console.WriteLine(i + "____" + ImageName);
}


Thank you!!!!
Posted
Updated 14-May-12 13:57pm
v2

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.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-May-12 17:33pm    
Sure, a 5.
--SA
Dr.Walt Fair, PE 14-May-12 21:19pm    
Path.GetFileNameWithoutExtension is what I use. +5
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900