Jonathan

Jonathan

  • NA
  • 3
  • 0

need help with a Class

Dec 19 2005 12:28 PM
I have this fileHandler class

using System;

using System.Data;

using System.Data.SqlClient;

using System.IO;

class fileHandler : IDisposable

{

private FileStream procs;

private StreamWriter sw;

private StreamReader sr;

public string file;

public fileHandler()

{

procs = null;

file = null;

sw = null;

sr = null;

}

public StreamWriter write2File(string filePath, FileMode Mode, FileAccess Access)

{

file = filePath;

procs = new FileStream(filePath, Mode, Access);

sw = new StreamWriter(procs);

return sw;

}

public StreamReader readFromFile(FileMode Mode, FileAccess Access)

{

procs = new FileStream(file, Mode, Access);

sr = new StreamReader(procs);

return sr;

}

Now in my code behind I have the following:

fileHandler hFirstFile = new fileHandler();

fileHandler hSecondFile = new fileHandler();

In my code I write output to 2 seperate files...when I go to use the variable file from each instance of my class, the first one is NULL(originally did get set) and the second one has a name.

I am wondering since they are 2 seperate instanciation, why are they being treated the same?