public static GetWorldName ( string WorldFileName ) : string | ||
WorldFileName | string | |
return | string |
public static string GetWorldName(string WorldFileName)
{
if (WorldFileName == null)
{
return string.Empty;
}
try
{
using (FileStream stream = new FileStream(WorldFileName, FileMode.Open))
{
using (BinaryReader reader = new BinaryReader(stream))
{
int num = reader.ReadInt32();
if ((num > 0) && (num <= Main.curRelease))
{
string str;
if (num <= 0x57)
{
str = reader.ReadString();
reader.Close();
return str;
}
if (num >= 0x87)
{
Stream baseStream = reader.BaseStream;
baseStream.Position += 20L;
}
reader.ReadInt16();
stream.Position = reader.ReadInt32();
str = reader.ReadString();
reader.Close();
return str;
}
}
}
}
catch
{
}
string[] strArray = WorldFileName.Split(new char[] { Path.DirectorySeparatorChar });
string str2 = strArray[strArray.Length - 1];
return str2.Substring(0, str2.Length - 4);
}