CFanatic

Go Back   CFanatic > Programming > C# Programming

Join CFanatic Forum Now

StreamWriter & xml reading problem topic posted under C# Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2008, 02:37 PM
Junior Member
 
Join Date: Jun 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Dumpen is on a distinguished road
| More
StreamWriter & xml reading problem

Hello.

I have this wierd problem when im writing to a text file with data from a array

I have this method:
Code:
		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:
Code:
			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:
Code:
			// 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:
Code:
<?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 With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating GUI Window after reading Each Channels rkannasri Win32 Programming 1 07-26-2008 05:01 PM
File I/O (Reading from a Random-Access File) VersEtreOuNe C++ Programming 0 02-12-2008 03:39 PM
Writing/reading 'records' to/from files. rpaul Introduce yourself 1 11-10-2007 12:10 PM
reading Excel file hadagali MFC Programming 0 08-23-2007 04:33 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:32 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board