   Read text file in Array (C#)
  Hello,I am trying to read  atext file into an array so I can say if TextFile==''g''{//draw ground sprite}but I cannot seem to get it working. Everything i try just is not working do you know how I can read a text file into an array because I am making a platform game and this needs to be done to continue!Thanks,Rob 
  Please post some of your code. It would be really helpful to at least know what the format of your text file is in to see what kind of information you need to pull into the array.    ----------------------------------"English? English? Why would I need to know English? I''m never going to England!" ;Here''s the code from my Log class, which can also read ascii and binary files and return them in an array using System;using System.Collections;using System.IO;namespace Utils.IO{/// <summary>/// The log class is able to log or extract messages from a user specified file/// </summary>public class Log{#region Membersprivate stringpath = "";private boolisBinary = false;#endregion#region Constructors/// <summary>/// Constructor/// </summary>/// <param name="name">The log path</param>public Log(string name){path = name;}/// <summary>/// Constructor/// </summary>/// <param name="name">The log path</param>/// <param name="binary">Indicates wether this instance is binary log</param>public Log(string name, bool binary) {path = name;isBinary = binary;}/// <summary>/// Constructor/// </summary>/// <param name="name">The log path</param>/// <param name="overwriteIfExists">If true, data already in specified log file will be overwritten</param>/// <param name="binary">Indicates wether this instance is binary log</param>public Log(string name, bool overwriteIfExists, bool binary) {path = name;isBinary = binary;if (overwriteIfExists) File.Delete(path);}#endregion#region Public Methods/// <summary>/// Writes a text to a the specified file (this includes a newline)/// </summary>/// <param name="item">The item to write to file</param>public void WriteLine(string item) {if (isBinary) {WriteBinary(item);return;}StreamWriter sw = GetTextStream();sw.WriteLine(item);sw.Close();}/// <summary>/// Writes a text to a the specified file (this does NOT include a newline)/// </summary>/// <param name="item">The item to write to file</param>public void Write(string item) {if (isBinary) {WriteBinary(item);return;}StreamWriter sw = GetTextStream();sw.Write(item);sw.Close();}/// <summary>/// Writes an object to file/// </summary>/// <param name="o">The object to render</param>public void WriteObject(object o) {WriteLine(o.ToString());}   /// <summary>/// Gets all the contents of the current log file/// </summary>/// <returns>An ArrayList containing a list of objects extracted from the current log file</returns>public ArrayList GetFileContents() {ArrayList al = new ArrayList();if (!File.Exists(path)) return al;if (isBinary) al = GetBinaryContents();elseal = GetTextContents();return al;}#endregion#region Private Methodsprivate StreamWriter GetTextStream() {StreamWriter sw;if (!File.Exists(path)) sw = File.CreateText(path);else sw = File.AppendText(path);return sw;}private void WriteBinary(string item) {FileStream fs;if (!File.Exists(path)) fs = new FileStream(path, FileMode.CreateNew);elsefs = new FileStream(path, FileMode.Append);BinaryWriter bw = new BinaryWriter(fs);bw.Write(item);bw.Close();fs.Close();}private ArrayList GetBinaryContents() {ArrayList al = new ArrayList();FileStream fs;if (!File.Exists(path)) return al;elsefs = new FileStream(path, FileMode.Open, FileAccess.Read);BinaryReader br = new BinaryReader(fs);string line;try {do {line = br.ReadString();al.Add(line);} while (line != "");}catch (EndOfStreamException) {}br.Close();fs.Close();return al;}private ArrayList GetTextContents() {ArrayList al = new ArrayList();StreamReader sr = new StreamReader(path);string line;while ((line = sr.ReadLine()) != null) {al.Add(line);}sr.Close();return al;}#endregion}}But if you ask me: you would be better of with an XML file. C# and .NET have excellent XML support. You can search, replace etc etc.. This would be far better for a game. Edo ;  How would I go about doing this in XML?Thanks,Rob ;  The file is a text file like thisGGGGGG:::GG:::GG:::GGGGGGthats my level in a text file all i want to do now is read that in to my application. So I can convert that text to the actul level are you with me? Thanks,Rob 