c# problem with string.contains()

  • Thread starter Thread starter Mion Shion
  • Start date Start date
M

Mion Shion

Guest
hello all,

i have wrote some code and trying to sort file names depending on names and saving them to a ini depending on what names are containing a certain string but i come across a problem i cant seem to fix so in short this is the code

public void getmodelnames()
{
var dirs = elfenliedtopfan5progsettings.Read("ModelPath", "ModelPaths");
string[] files = Directory.GetFiles(dirs,"*.xmodel_bin*", SearchOption.AllDirectories);




// Display all the files.
_MessageResult.Instance.Append("XMODEL BIN FILES ENTRIES" + Environment.NewLine);






//string[] allFiles = System.IO.Directory.GetFiles(elfenliedtopfan5progsettings.Read("ModelPath", "ModelPaths"));//Change path to yours
foreach (string found in files)
{
string elfenpath = Path.GetFileNameWithoutExtension(found);
setmodel(found, elfenpath);
}







_MessageResult.Instance.Append("XMODEL BIN FILES ENTRIES END" + Environment.NewLine);



}


public void setmodel(string set,string name)
{
string elf = Path.GetFileNameWithoutExtension(set);

XtraMessageBox.Show("Match Found : " + elf);


if(elf.Contains("wm"))
{
// WM STUFF
if (elf.Contains("wm"))
{
if (elf.Contains("wm_mag"))
{
elfenliedtopfan5progsettings.Write("WorldModelMag", elf, "WM_MAG");
}
else
{
if (elf.Contains("upg"))
{
elfenliedtopfan5progsettings.Write("WorldModelUpgraded", elf, "WM_UG");
}
else
{
if (elf.Contains("ug"))
{
elfenliedtopfan5progsettings.Write("WorldModelUpgraded", elf, "WM_UG");
}
else
{
elfenliedtopfan5progsettings.Write("WorldModel", elf, "WM");
}
}
}

}


}
else
{
// VM STUFF
if(elf.Contains("vm"))
{


if (elf.Contains("vm"))
{
if (elf.Contains("vm_ug"))
{
elfenliedtopfan5progsettings.Write("ViewModelUpgraded", elf, "VM_UG");
}
else
{
if (elf.Contains("upg"))
{
elfenliedtopfan5progsettings.Write("ViewModelUpgraded", elf, "VM_UG");
}
else
{
elfenliedtopfan5progsettings.Write("ViewModel", elf, "VM");
}
}



}
}
else
{
if(elf.Contains("animated"))
{


if(elf.Contains("ug"))
{
elfenliedtopfan5progsettings.Write("AnimatedUPG", elf, "AM");
}
else
{
elfenliedtopfan5progsettings.Write("Animated", elf, "AM");
}

}
}


}
}


and this will look in the model folder where you select and you should find the following kind of files.

hhslEBy.png

and all it will get is the .xmodel bin files and then get the file names the issue im having is

some of the names are different like instead of vm its view model

or not ug its upgraded or upg

is there a better way of getting strings and divining wm vm upgaded_vm ect


example what people could name them

weaponname_vm

weaponname_wm

weaponname_upgraded

weaponname_up

weaponname_upg

weaponname_animated

weaponname_animated_ug

what i need to do is find a better way than doing what im doing now witch is name.contains as it not always working and was wondering if there was a better and more solid way of doing this


thank you in advance Mion Shion.

Continue reading...
 
Back
Top