J
joey.powell
I am writing a class that will do some binary file IO. The class will
need to read a header from the binary file, and it will also need to
read a varying number of records in the file. I currently have two main
methods: Open(string FilePath) and Close(). I would like to read all of
the data into variables whenever Open is called. I would like to have a
Header (sub?)class within the main class, and maybe a collection or
array for the records. The following is a snippet of what I have so
far...
========================
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace MyNameSpace
{
public class MyClass
{
private FileStream fsMyFile;
private BinaryReader brMyFile;
public void Open(string FilePath)
{
fsMyFile = new FileStream(FilePath, FileMode.Open,
FileAccess.ReadWrite);
brMyFile = new BinaryReader(fsMyFile);
Header.MyCode = 2;
}
public void Close()
{
brMyFile.Close();
fsMyFile.Close();
}
public static class Header
{
private static int _MyCode;
public static int MyCode
{
get { return _MyCode; }
set { _MyCode = value; }
}
}
}
}
========================
I want to be able to reference this dll to other projects and then use
it like...
MyClass someclass = new MyClass();
someclass.Open("[path to file]");
TextBox1.Text = (someclass.Header.MyCode).ToString();
someclass.Close();
How can I get the someclass.Header.MyCode syntax to work? Will it not
work now because I am putting the header class inside the main class?
Are you confused as I am?
Any suggestions would be appreciated.
need to read a header from the binary file, and it will also need to
read a varying number of records in the file. I currently have two main
methods: Open(string FilePath) and Close(). I would like to read all of
the data into variables whenever Open is called. I would like to have a
Header (sub?)class within the main class, and maybe a collection or
array for the records. The following is a snippet of what I have so
far...
========================
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace MyNameSpace
{
public class MyClass
{
private FileStream fsMyFile;
private BinaryReader brMyFile;
public void Open(string FilePath)
{
fsMyFile = new FileStream(FilePath, FileMode.Open,
FileAccess.ReadWrite);
brMyFile = new BinaryReader(fsMyFile);
Header.MyCode = 2;
}
public void Close()
{
brMyFile.Close();
fsMyFile.Close();
}
public static class Header
{
private static int _MyCode;
public static int MyCode
{
get { return _MyCode; }
set { _MyCode = value; }
}
}
}
}
========================
I want to be able to reference this dll to other projects and then use
it like...
MyClass someclass = new MyClass();
someclass.Open("[path to file]");
TextBox1.Text = (someclass.Header.MyCode).ToString();
someclass.Close();
How can I get the someclass.Header.MyCode syntax to work? Will it not
work now because I am putting the header class inside the main class?
Are you confused as I am?
Any suggestions would be appreciated.