TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Casper Hansen
NA
14
0
StreamWriter & xml reading problem
Jul 2 2008 3:38 PM
Hello.
I have this wierd problem when im writing to a text file with data from a array
I have this method:
private void writeData()
{
// Open file
StreamWriter writeData = new StreamWriter(saveMonsterSetBase.FileName, false);
// Write all data from array to file
for (int x = 0; x < MonsterSetBaseDataArray.Count; x++)
{
writeData.WriteLine(MonsterSetBaseDataArray[x]);
}
// Close stream
writeData.Close();
}
Which is trigged here:
saveMonsterSetBase.ShowDialog();
if (saveMonsterSetBase.FileName != "")
{
writeData();
}
It works fine and opens my saveFileDialog
But after I save it I get a "file not found" on some other method I use
This is some of the method:
// Opening txt file with location from XML
StreamReader findMonsterStream = new StreamReader(@XMLmonsterLocation);
I get the error monster.txt (XMLmonsterLocation) is not found
It looks like the writedata changes the local path because it says
File not found in the path where I saved the file
Example:
The application and monster.txt (XMLmonsterLocation) is saved in D:\
I then use the saveFileDialog (I save a file to for example C:\) and when I access my method where I use the XMLmonsterLocation it says file not found in C:\
So I dont know why
Hope you understand
The StreamReader reads from a xml file that looks like this:
<?xml version='1.0'?>
<config>
<monsterLocation>monster.txt</monsterLocation>
<monsterSetBaseLocation>MonsterSetBase.txt</monsterSetBaseLocation>
<monsterImageLocation>mobs\</monsterImageLocation>
<mapImageLocation>maps\</mapImageLocation>
<mapInfoLocation>maps\maps.txt</mapInfoLocation>
</config>
Reply
Answers (
1
)
Need help with how to read database data of apriori unknown size into a 2D array.
Importing C Dll to C#