I have been trying this for days now and I am not even sure if I am going about this right. I've got errors errors errors everywhere. What I am trying to do is write a windows app that maintains a contact book that can hold up to 20 entries. I can store my data with arrys or classes.
Each entry has Last and first name, street, city, state and zip.
-I need menu functionality for Open and Save the file.
-Display the whole address book (just names in alpha order)
-Display all info about an individual that a user selects. (i used buttons for the two display options.)
-Add address book entry (btnAdd)
-Delete Address Book entry (btnDelete)

Now the only time they should be using the text file is:
1. when the user first chooses to open an address book (data is read into the classes. (I'm assuming I use StreamReader)
2. when the user chooses to save an address book file or close the program (data is written from the classes. (streamWriter??)

I am extremely confused about the whole thing and I'm not even sure I am even going about this correctly.
Can anyone help? Any help will be greatly appreciated.
This is what I have:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;

namespace ProjectTen
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class frmAddress : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.SaveFileDialog saveFileDialog1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.MainMenu mainMenu2;
		private System.Windows.Forms.MenuItem menuFile;
		private System.Windows.Forms.MenuItem menuOpen;
		private System.Windows.Forms.MenuItem menuSave;
		private System.Windows.Forms.Button btnDisplayContact;
		private System.Windows.Forms.Button btnAdd;
		private System.Windows.Forms.Button btnDelete;
		private System.Windows.Forms.Button btnDisplayAll;
		private StreamReader iFile;
		private StreamWriter oFile;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.OpenFileDialog openFD;
		private System.Windows.Forms.SaveFileDialog saveFD;
		private System.Windows.Forms.ListBox lstBoxDisplay;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		

		public frmAddress()
		{
			
		}

		private void btnDisplayContact_Click(object sender, System.EventArgs e)
		{
			int displayContact = lstBoxDisplay.Items.Count;
			string[] lastName = new string[displayContact];
		
			for (int l = 0; l < displayContact; l++)
			{
				lastName[l] = Convert.ToString(lstBoxDisplay.Items[l]);
			}
		
			Array.Sort(lastName);
			lstBoxDisplay.Items.Clear();
		
			lstBoxDisplay.Items.AddRange(lastName);                    

		}

		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			this.lstBoxDisplay.Items.Add();
		}

		private void btnDisplayAll_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show(firstName + "\n" + lastName + "\n" + address + "\n" +
				city + "\n" + state + "\n" + zipCode);

		}

		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			if (lastName.Items.Count < 1)
			{
				MessageBox.Show("There are no items to delete");
			}
			else if (lstBoxDisplay.Text == "")
			{
				MessageBox.Show("Please select an item to delete");
			}
			else
			{
				DialogResult button = MessageBox.Show(
				"Do you want to perform this action?",                                                                                                                                                                                   			
				MessageBoxButtons.YesNo,                                                        			
					MessageBoxIcon.Question,                                                       			
					MessageBoxDefaultButton.Button2 ); 
				if (button == DialogResult.Yes)
				{
					lstBoxDisplay.Items.RemoveAt(lstBoxDisplay.SelectedIndex);     
				}
			

			}
			

		}

		private void menuSave_Click(object sender, System.EventArgs e)
		{
			string Saved_File = "Address.txt";
			saveFD.InitialDirectory = "";
			saveFD.Title = "Save";
			saveFD.FileName = "Address.txt";
			saveFD.Filter = "Text Files|*.txt";
			if (saveFD.ShowDialog() != DialogResult.Cancel)
			{
				Saved_File = saveFD.Address.txt;
				
			}

		}
		
		
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		
		
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmAddress());

		}

		

		private void InitializeComponent()
		{
			this.mainMenu2 = new System.Windows.Forms.MainMenu();
			this.menuFile = new System.Windows.Forms.MenuItem();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuOpen = new System.Windows.Forms.MenuItem();
			this.menuSave = new System.Windows.Forms.MenuItem();
			this.btnDisplayContact = new System.Windows.Forms.Button();
			this.btnAdd = new System.Windows.Forms.Button();
			this.btnDelete = new System.Windows.Forms.Button();
			this.btnDisplayAll = new System.Windows.Forms.Button();
			this.openFD = new System.Windows.Forms.OpenFileDialog();
			this.saveFD = new System.Windows.Forms.SaveFileDialog();
			this.lstBoxDisplay = new System.Windows.Forms.ListBox();
			this.SuspendLayout();
			// 
			// mainMenu2
			// 
			this.mainMenu2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuFile});
			// 
			// menuFile
			// 
			this.menuFile.Index = 0;
			this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuItem1,
																					 this.menuOpen,
																					 this.menuSave});
			this.menuFile.Text = "File";
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.Text = "-";
			// 
			// menuOpen
			// 
			this.menuOpen.Index = 1;
			this.menuOpen.Text = "Open";
			this.menuOpen.Click += new System.EventHandler(this.menuOpen_Click);
			// 
			// menuSave
			// 
			this.menuSave.Index = 2;
			this.menuSave.Text = "Save";
			this.menuSave.Click += new System.EventHandler(this.menuSave_Click);
			// 
			// btnDisplayContact
			// 
			this.btnDisplayContact.Location = new System.Drawing.Point(165, 205);
			this.btnDisplayContact.Name = "btnDisplayContact";
			this.btnDisplayContact.Size = new System.Drawing.Size(100, 23);
			this.btnDisplayContact.TabIndex = 0;
			this.btnDisplayContact.Text = "Display Contact";
			this.btnDisplayContact.Click += new System.EventHandler(this.btnDisplayContact_Click);
			// 
			// btnAdd
			// 
			this.btnAdd.Location = new System.Drawing.Point(20, 165);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new System.Drawing.Size(100, 23);
			this.btnAdd.TabIndex = 1;
			this.btnAdd.Text = "Add Entry";
			this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
			// 
			// btnDelete
			// 
			this.btnDelete.Location = new System.Drawing.Point(165, 165);
			this.btnDelete.Name = "btnDelete";
			this.btnDelete.Size = new System.Drawing.Size(100, 23);
			this.btnDelete.TabIndex = 2;
			this.btnDelete.Text = "Delete Entry";
			this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
			// 
			// btnDisplayAll
			// 
			this.btnDisplayAll.Location = new System.Drawing.Point(20, 205);
			this.btnDisplayAll.Name = "btnDisplayAll";
			this.btnDisplayAll.Size = new System.Drawing.Size(100, 23);
			this.btnDisplayAll.TabIndex = 3;
			this.btnDisplayAll.Text = "Display All";
			this.btnDisplayAll.Click += new System.EventHandler(this.btnDisplayAll_Click);
			// 
			// lstBoxDisplay
			// 
			this.lstBoxDisplay.Location = new System.Drawing.Point(20, 20);
			this.lstBoxDisplay.Name = "lstBoxDisplay";
			this.lstBoxDisplay.Size = new System.Drawing.Size(240, 121);
			this.lstBoxDisplay.TabIndex = 4;
			// 
			// frmAddress
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(224)), ((System.Byte)(192)));
			this.ClientSize = new System.Drawing.Size(284, 264);
			this.Controls.Add(this.lstBoxDisplay);
			this.Controls.Add(this.btnDisplayAll);
			this.Controls.Add(this.btnDelete);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.btnDisplayContact);
			this.Menu = this.mainMenu2;
			this.Name = "frmAddress";
			this.Text = "Address Book";
			this.Load += new System.EventHandler(this.frmAddress_Load_1);
			this.ResumeLayout(false);

		}

		private void frmAddress_Load_1(object sender, System.EventArgs e)
		{
		
		}

		private void menuOpen_Click(object sender, System.EventArgs e)
		{
			String[] firstName = {"Julie", "Tony", "Frederick", "Betty", "Paul", "David", "Heather"};
			String[] lastName = {"Ostendoft", "Bush", "Slater", "Gardner", "Rivers", "Lee", "Small"};
			String[] address = {"123 Fort St.", "456 Comp St.", "789 Blue Ave", "3452 Missouri Rd.", "43418 Old River Rd.", "457 Addy Ct.", "4233 Harvey St."};
			String[] city = {"Baltimore", "Dallas", "Fort Worth", "Owings Mills", "Miami", "Colorado Springs", "Los Angeles"};
			String[] state = {"Maryland", "Texas", "Texas", "Maryland", "Florida", "Colorado", "California"};
			String[] zipCode = {"21234", "12345", "67890", "32345", "43418", "31241", "31489", "83974"};

			StreamReader iFile = new StreamReader("Address.txt");
			for(int i = 0; i < lastName.Length; i++)
	
				iFile.WriteLine(lastName[i] + "," + lastName[i] + "\n" + address[i] + "\n" +
					city[i] + "\n" + state[i] + "\n" + zipCode[i]);
			iFile.Close();
		}
			
			
		public frmAddress(string fName, string lName)
		{
			firstName = fName;
			lastName = lName;
		}
		public string FName
		{
			get
			{
				return firstName;
			}
		}
		public string LName
		{
			get
			{
				return lastName;
			}
		}
		public string Address
		{
			get
			{
				return address;
			}
		}
		public string City
		{
			get
			{
				return city;
			}
		}
		public string State
		{
			get
			{
				return state;
			}
		}
		public string Zip
		{
			get
			{
				return zipCode;
			}	
		}
		
	}
}

Recommended Answers

All 9 Replies

Oh... where to start... Since you do nothing in the Load event, I assume you press a button or something that causes your first noticeable error? Regardless, let's start with your first noticeable error--where does this happen?

private void btnAdd_Click(object sender, System.EventArgs e)
		{
			this.lstBoxDisplay.Items.Add();
		}

No overload
Then in other events it says that firstname, lastname, etc. cannot be found. I guess I am confused about where to put some of the code. Would I put the array in the load event? If so, how could I get it to open the text file when i click the open event?

I'm getting no overload event for MessageBoxShow in my Delete event as well. It's such a mess. I have 17 errors in total. :(

System.Windows.Forms.SaveFileDialog' does not contain a definition for 'Address'


cannot convert from 'System.Windows.Forms.MessageBoxButtons' to 'string'

cannot convert from 'System.Windows.Forms.MessageBoxIcon' to 'System.Windows.Forms.MessageBoxButtons'

cannot convert from 'System.Windows.Forms.MessageBoxDefaultButton' to 'System.Windows.Forms.MessageBoxIcon'

No overload for method 'Add' takes '0' arguments

The best overloaded method match for 'System.Windows.Forms.MessageBox.Show(string, string, System.Windows.Forms.MessageBoxButtons, System.Windows.Forms.MessageBoxIcon)' has some invalid arguments

The name 'address' does not exist in the class or namespace ProjectTen.frmAddress'

The name 'city' does not exist in the class or namespace ProjectTen.frmAddress'

The name 'firstName' does not exist in the class or namespace ProjectTen.frmAddress'

The name 'firstName' does not exist in the class or namespace ProjectTen.frmAddress'

The name 'firstName' does not exist in the class or namespace ProjectTen.frmAddress'

The name 'lastName' does not exist in the class or namespace ProjectTen.frmAddress'

The name 'lastName' does not exist in the class or namespace ProjectTen.frmAddress'

The name 'zipCode' does not exist in the class or namespace ProjectTen.frmAddress'

The type or namespace name 'lastName' could not be found (are you missing a using directive or an assembly reference?)

OK. You are in over your head on this I think. So, let's take this a step at a time and see if you can accelerate your understanding of compiler errors and how to reference/interpret the meaning:

Error 4 No overload for method 'Add' takes '0' arguments

private void btnAdd_Click(object sender, System.EventArgs e)
        {
            this.lstBoxDisplay.Items.Add();
        }

This is telling you that the Add() method you are calling requires parameter(s). In other words, you need to give it something to add:

private void btnAdd_Click(object sender, System.EventArgs e)
        {
            string apples = "apples";
            string oranges = "oranges";
            this.lstBoxDisplay.Items.Add(apples);
            this.lstBoxDisplay.Items.Add(oranges);
        }

Above will add two items: apples and oranges.

Given you are working with a contact list, you items will be different. Also, they don't have to be strings. However, to display properly in your list box, the ToString() method will need to return the appropriate string representation--done automatically above because apples and oranges are both declared string objects.

Here is the best part: If you are using Visual Studio, you can right click on a method (like Add()), and select go to definition, which will tell you how the method expects to be called. Also, if you press F1 while in the Error list, hopefully (doesn't always work), it will take you to the help for this error.

I feel you might be in over your head on this. Play around with the environment given this information and become more comfortable in understanding the tools you have to resolve these compile errors. Fix as many as you can, then come back with the few you can't figure out.

Good luck.

--David

Ok that helps. I have it down to two errors. YAY. Of course, that doesn't mean that it's doing what I want it to but I'll come to that as soon as I can test it.
I don't understand how to get this to work without WriteLine though.

private void menuOpen_Click(object sender, System.EventArgs e)
		{
			String[] firstName = {"Julie", "Tony", "Frederick", "Betty", "Paul", "David", "Heather"};
			String[] lastName = {"Ostendoft", "Bush", "Slater", "Gardner", "Rivers", "Lee", "Small"};
			String[] address = {"123 Fort St.", "456 Comp St.", "789 Blue Ave", "3452 Missouri Rd.", "43418 Old River Rd.", "457 Addy Ct.", "4233 Harvey St."};
			String[] city = {"Baltimore", "Dallas", "Fort Worth", "Owings Mills", "Miami", "Colorado Springs", "Los Angeles"};
			String[] state = {"Maryland", "Texas", "Texas", "Maryland", "Florida", "Colorado", "California"};
			String[] zipCode = {"21234", "12345", "67890", "32345", "43418", "31241", "31489", "83974"};

			StreamReader iFile = new StreamReader("Address.txt");
			for(int i = 0; i < lastName.Length; i++)
	
				iFile.WriteLine(lastName[i] + "," + lastName[i] + "\n" + address[i] + "\n" +
					city[i] + "\n" + state[i] + "\n" + zipCode[i]);
			iFile.Close();
		}

The error I am getting is:
'System.IO.StreamReader' does not contain a definition for 'WriteLine'

I tried ReadToEnd but that gives me this error:
No overload for method 'ReadToEnd' takes '1' arguments

Use StreamWriter.

Use StreamWriter.

WAIT!!! Are you trying to read or write? -- LOL

Ok I've changed everything around and it compiles and runs. Save seems to be working ok so far. Nothing happens when I try to open the file though. My Dialog box pops up but the file doesn't open and the same goes for Display Contact and Display all. What am I doing wrong? This is what I have. Will post the whole thing so you can see the changes. Copy and paste my code so you can see what I am talking about.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;

namespace ProjectTen
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class frmAddress : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuFile;
		private System.Windows.Forms.MenuItem menuOpen;
		private System.Windows.Forms.MenuItem menuSave;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.ListBox lstBoxDisplay;
		private System.Windows.Forms.Button btnAdd;
		private System.Windows.Forms.Button btnDisplayAll;
		private System.Windows.Forms.Button btnDelete;
		private StreamReader iFile;
		private StreamWriter oFile;

		private string lastName;
		private string firstName;
		private string address;
		private string city;
		private string state;
		private string zipCode;
		private System.Windows.Forms.Button btnDisplayContact;
		private System.Windows.Forms.SaveFileDialog saveFD;
		private System.Windows.Forms.OpenFileDialog openFD;



		private System.ComponentModel.Container components = null;

		public frmAddress()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		private void saveFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
		{
		
		}

		private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
		{
		
		}

		private void btnDisplayRecord_Click(object sender, System.EventArgs e)
		{
			int displayContact = lstBoxDisplay.Items.Count;
			string[] lastName = new string[displayContact];
		
			for (int l = 0; l < displayContact; l++)
			{
				lastName[l] = Convert.ToString(lstBoxDisplay.Items[l]);
			}
		
			Array.Sort(lastName);
			lstBoxDisplay.Items.Clear();
		
			lstBoxDisplay.Items.AddRange(lastName);   
		}

		private void btnDisplayAll_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show(firstName + "\n" + lastName + "\n" + address + "\n" +
				city + "\n" + state + "\n" + zipCode);
		}

		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			if (lastName.Length < 1)
			{
				MessageBox.Show("There are no items to delete");
			}
			else if (lstBoxDisplay.Text == "")
			{
				MessageBox.Show("Please select an item to delete");
			}
			else
			
				lstBoxDisplay.Items.RemoveAt(lstBoxDisplay.SelectedIndex);  
		}

		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			this.lstBoxDisplay.Items.Add(lastName);
			this.lstBoxDisplay.Items.Add(firstName);
			this.lstBoxDisplay.Items.Add(address);
			this.lstBoxDisplay.Items.Add(city);
			this.lstBoxDisplay.Items.Add(state);
			this.lstBoxDisplay.Items.Add(zipCode);
		}

		private void menuSave_Click(object sender, System.EventArgs e)
		{
			string Saved_File = "Address.txt";
			saveFD.InitialDirectory = "";
			saveFD.Title = "Save";
			saveFD.FileName = "Address.txt";
			saveFD.Filter = "Text Files|*.txt";
			if (saveFD.ShowDialog() != DialogResult.Cancel)
			{
				Saved_File = saveFD.FileName;
				
			}
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuFile = new System.Windows.Forms.MenuItem();
			this.menuOpen = new System.Windows.Forms.MenuItem();
			this.menuSave = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.lstBoxDisplay = new System.Windows.Forms.ListBox();
			this.btnAdd = new System.Windows.Forms.Button();
			this.btnDisplayAll = new System.Windows.Forms.Button();
			this.btnDelete = new System.Windows.Forms.Button();
			this.btnDisplayContact = new System.Windows.Forms.Button();
			this.saveFD = new System.Windows.Forms.SaveFileDialog();
			this.openFD = new System.Windows.Forms.OpenFileDialog();
			this.SuspendLayout();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuFile});
			// 
			// menuFile
			// 
			this.menuFile.Index = 0;
			this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuOpen,
																					 this.menuItem4,
																					 this.menuSave});
			this.menuFile.Text = "File";
			// 
			// menuOpen
			// 
			this.menuOpen.Index = 0;
			this.menuOpen.Text = "Open";
			this.menuOpen.Click += new System.EventHandler(this.menuOpen_Click);
			// 
			// menuSave
			// 
			this.menuSave.Index = 2;
			this.menuSave.Text = "Save";
			this.menuSave.Click += new System.EventHandler(this.menuSave_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 1;
			this.menuItem4.Text = "-";
			// 
			// lstBoxDisplay
			// 
			this.lstBoxDisplay.Location = new System.Drawing.Point(15, 20);
			this.lstBoxDisplay.Name = "lstBoxDisplay";
			this.lstBoxDisplay.Size = new System.Drawing.Size(255, 108);
			this.lstBoxDisplay.TabIndex = 0;
			// 
			// btnAdd
			// 
			this.btnAdd.Location = new System.Drawing.Point(20, 160);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new System.Drawing.Size(100, 23);
			this.btnAdd.TabIndex = 1;
			this.btnAdd.Text = "Add Contact";
			this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
			// 
			// btnDisplayAll
			// 
			this.btnDisplayAll.Location = new System.Drawing.Point(20, 220);
			this.btnDisplayAll.Name = "btnDisplayAll";
			this.btnDisplayAll.Size = new System.Drawing.Size(100, 23);
			this.btnDisplayAll.TabIndex = 2;
			this.btnDisplayAll.Text = "Display All";
			this.btnDisplayAll.Click += new System.EventHandler(this.btnDisplayAll_Click);
			// 
			// btnDelete
			// 
			this.btnDelete.Location = new System.Drawing.Point(160, 160);
			this.btnDelete.Name = "btnDelete";
			this.btnDelete.Size = new System.Drawing.Size(100, 23);
			this.btnDelete.TabIndex = 3;
			this.btnDelete.Text = "Delete Contact";
			this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
			// 
			// btnDisplayContact
			// 
			this.btnDisplayContact.Location = new System.Drawing.Point(160, 220);
			this.btnDisplayContact.Name = "btnDisplayContact";
			this.btnDisplayContact.Size = new System.Drawing.Size(100, 23);
			this.btnDisplayContact.TabIndex = 4;
			this.btnDisplayContact.Text = "Display Contact";
			this.btnDisplayContact.Click += new System.EventHandler(this.btnDisplayRecord_Click);
			// 
			// saveFD
			// 
			this.saveFD.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog1_FileOk);
			// 
			// openFD
			// 
			this.openFD.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
			// 
			// frmAddress
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(224)), ((System.Byte)(192)));
			this.ClientSize = new System.Drawing.Size(284, 284);
			this.Controls.Add(this.btnDisplayContact);
			this.Controls.Add(this.btnDelete);
			this.Controls.Add(this.btnDisplayAll);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.lstBoxDisplay);
			this.Menu = this.mainMenu1;
			this.Name = "frmAddress";
			this.Text = "Address Book";
			this.Load += new System.EventHandler(this.frmAddress_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmAddress());
		}

		private void frmAddress_Load(object sender, System.EventArgs e)
		{
			String[] firstName = {"Julie", "Tony", "Frederick", "Betty", "Paul", "David", "Heather"};
			String[] lastName = {"Ostendoft", "Bush", "Slater", "Gardner", "Rivers", "Lee", "Small"};
			String[] address = {"123 Fort St.", "456 Comp St.", "789 Blue Ave", "3452 Missouri Rd.", "43418 Old River Rd.", "457 Addy Ct.", "4233 Harvey St."};
			String[] city = {"Baltimore", "Dallas", "Fort Worth", "Owings Mills", "Miami", "Colorado Springs", "Los Angeles"};
			String[] state = {"Maryland", "Texas", "Texas", "Maryland", "Florida", "Colorado", "California"};
			String[] zipCode = {"21234", "12345", "67890", "32345", "43418", "31241", "31489", "83974"};

			StreamReader iFile = new StreamReader("Address.txt");
			StreamWriter oFile = new StreamWriter("Address2.txt");
			for(int i = 0; i < lastName.Length; i++)				
				
				oFile.Write(String.Format((lastName[i] + "," + lastName[i] + "\n" + address[i] + "\n" +
					city[i] + "\n" + state[i] + "\n" + zipCode[i])));
			oFile.Close();
			oFile.Close();
		}
			
			
		public frmAddress(string fName, string lName)
		{
			firstName = fName;
			lastName = lName;
		}
		public string FName
		{
			get
			{
				return firstName;
			}
		}
		public string LName
		{
			get
			{
				return lastName;
			}
		}
		public string Address
		{
			get
			{
				return address;
			}
		}
		public string City
		{
			get
			{
				return city;
			}
		}
		public string State
		{
			get
			{
				return state;
			}
		}
		public string Zip
		{
			get
			{
				return zipCode;
			}	
		}
	

		private void menuOpen_Click(object sender, System.EventArgs e)
		{
			string Chosen_File = "Address.txt";
			openFD.InitialDirectory = "";
			openFD.Title = "Open";
			openFD.FileName = "Address.txt";
			openFD.Filter = "Text Files|*.txt";
			if (openFD.ShowDialog() != DialogResult.Cancel)
				{
				Chosen_File = openFD.FileName;
				}
				
		}
	}
}

One more thing while I think of it. This is the text file I am using to read from and store in the array. Should I be using a special character after each line or maybe one after each entry of name, address, city, state and zip?

Ostendorf, Julie
123 Fort St.
Baltimore
Maryland
21234
Bush, Tony
456 Comp St.
Dallas
Texas
12345
Slater, Frederick
789 Blue Ave.
Fort Worth
Texas
67890
Gardner, Betty
3452 Missouri Rd.
Owings Mills
Maryland
32345
Rivers, Paul
43418 Old River Rd.
Miami
Florida
31241
Lee, David
457 Addy Ct.
Colorado Springs
Colorado
31489
Small, Heather
4233 Harvey St.
Los Angeles
California
83974

private void frmAddress_Load(object sender, System.EventArgs e)
        {
            String[] firstName = { "Julie", "Tony", "Frederick", "Betty", "Paul", "David", "Heather" };
            String[] lastName = { "Ostendoft", "Bush", "Slater", "Gardner", "Rivers", "Lee", "Small" };
            String[] address = { "123 Fort St.", "456 Comp St.", "789 Blue Ave", "3452 Missouri Rd.", "43418 Old River Rd.", "457 Addy Ct.", "4233 Harvey St." };
            String[] city = { "Baltimore", "Dallas", "Fort Worth", "Owings Mills", "Miami", "Colorado Springs", "Los Angeles" };
            String[] state = { "Maryland", "Texas", "Texas", "Maryland", "Florida", "Colorado", "California" };
            String[] zipCode = { "21234", "12345", "67890", "32345", "43418", "31241", "31489", "83974" };

            StreamReader iFile = new StreamReader("Address.txt");
            StreamWriter oFile = new StreamWriter("Address2.txt");
            for (int i = 0; i < lastName.Length; i++)

                oFile.Write(String.Format((lastName[i] + "," + lastName[i] + "\n" + address[i] + "\n" +
                    city[i] + "\n" + state[i] + "\n" + zipCode[i])));
            oFile.Close();
            oFile.Close();
        }


1) You are never reading from your input file--you have hard coded the information.
2) You are writing your lastname field twice
3) You are closing your output file twice, but never you input file.

Regarding you other question about whether you should have a delimiter after every line: not necessary because the EOL <CR/LF> is your delimiter separating the fields as far as I can tell.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.