Problem with Strings

Hi:

I read information of a XML like this:

name = ass_reader.GetAttribute("File3D");

But name’s information is this:

resources\3dfiles\excavadora_2\plaquita.3ds

I only need the word plaquita. I need to save this word in a string but I don’t know how.

I have done this, what is the problem?

lon = nombre.Length;
for (index=31; index<lon-3;index++)
{
nombreSTR [index2] == nombre [index];
index2++;
}

Sorry for my bad english

Are you sure it’s not “resources/3dfiles/excavadora_2/plaquita.3ds”?

Because backslashes represent an escape character.

You can get the filename like so:

var mypath : String = "resources/3dfiles/excavadora_2/plaquita.3ds";
var parts : Array = mypath.Split("/" [0]); //create array using "/" as delimiter
var nameAndExtension = parts[parts.length-1]; //get last element of array
var fileName = nameAndExtension.Split("." [0])[0]; //remove extension
Debug.Log(fileName);

Alternately (less memory usage):

var mypath = "resources/3dfiles/excavadora_2/plaquita.3ds";
var lastIndex = mypath.LastIndexOf("/"[0])+1;
var fileName = mypath.Substring(lastIndex, mypath.Length-lastIndex-4);
print (fileName);

Assuming that you know the extension is always 4 chars including the “.”

–Eric