Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C# Programming

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-02-2008, 02:38 PM
Dumpen Dumpen is offline
Newbie
 
Join Date: Jun 2008
Posts: 6
Credits: 0
Rep Power: 0
Dumpen is on a distinguished road
Default 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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-03-2008, 01:13 PM
gorkempacaci gorkempacaci is offline
Newbie
 
Join Date: Jul 2008
Location: Dundee, UK
Posts: 1
Credits: 0
Rep Power: 0
gorkempacaci is on a distinguished road
Default Re: StreamWriter & xml reading problem

Sorry, I can't say I understood your problem.
Do you want to write exact paths to your files into xml instead of relative paths?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Peculiar UI Problem Needs Tackling adriyel C# Programming 2 04-06-2008 07:46 AM
MFC FTP Wininet API read problem mukul C and C++ 0 02-29-2008 02:12 AM
How to tackle a programming problem? TcM General Programming 10 01-07-2008 11:29 AM
[C] Comparison problem Alhazred C and C++ 1 08-29-2007 04:58 AM


All times are GMT -5. The time now is 12:57 AM.

Contest Stats

Xav ........ 1333.07
MeTh0Dz|Reb0rn ........ 1059.52
John ........ 887.37
morefood2001 ........ 879.43
marwex89 ........ 869.98
WingedPanther ........ 851.68
Brandon W ........ 764.23
chili5 ........ 312.39
Steve.L ........ 254.16
dcs ........ 225.25

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads