I have been working on a big project, and today I tried to make an executable from it with microsoft visual studio 2010. This worked, but when try to run it the program will stop. This is probably because my function "public List load(int levelnumber)" cant find a projectpath. Because this one is made meanwhile compiling. My XML are in C:\test4\myLevels\ and my exe is in my C:\test folder. I put the myLevels folder with the XML files in the C:\test4\ folder by myself. Sorry for my bad english. Any help is welcome!
Error (in dutch, no idea how to change this to english):
Bestanden die helpen bij het beschrijven van het probleem:
C:\Users\woutr\AppData\Local\Temp\WER9F14.tmp.WERInternalMetadata.xml
C:\Users\woutr\AppData\Local\Temp\WERD03.tmp.appcompat.txt
C:\Users\woutr\AppData\Local\Temp\WERD81.tmp.mdmp Lees de
onlineprivacyverklaring: http://ift.tt/1lTnmyE
Als de onlineprivacyverklaring niet beschikbaar is, lees dan onze
offlineprivacyverklaring: C:\Windows\system32\nl-NL\erofflps.txt
Photo of how the error looks like: imgur.com/77iAOGe
XML class:
public class XML
{
public void save(List<Sprite> sprites, int levelnumber)
{
XmlSerializer serializer = new XmlSerializer(typeof(List<Sprite>));
CreateDirectory("myLevels");
TextWriter textWriter = new StreamWriter(GetProjectPath() + @"\x86\Debug\myLevels\level_" + levelnumber + ".xml");
serializer.Serialize(textWriter, sprites);
textWriter.Close();
}
public List<Sprite> load(int levelnumber)
{
XmlSerializer deserializer = new XmlSerializer(typeof(List<Sprite>));
TextReader textReader = new StreamReader(GetProjectPath() + @"\x86\Debug\myLevels\level_" + levelnumber + ".xml");
List<Sprite> sprites = (List<Sprite>)deserializer.Deserialize(textReader);
textReader.Close();
return sprites;
}
private String GetProjectPath()
{
return Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
}
private void CreateDirectory(string path)
{
if (!Directory.Exists(path))
{
DirectoryInfo dir = Directory.CreateDirectory(path);
}
}
}
No comments:
Post a Comment