thx for the reply,
I suppose I should answer number 4 first. No i have no control over the file format. The file format is a type of postscript file that has images within which are converted to binary (from hex data) before writing.. an example of this

short)
Code:
/CIP3PreviewImageCompression /None def
CIP3PreviewImage
... Binary Hex Data Here
...more text here
...more binary hex data
....
I apologies for some unreadable parts, there is a lot of test data in here.
Q1 I am Using filelen only to find the length of the file, that way when i am counting my way through the characters, when i get to the end of the file my counter should be the same as filelen?
Q2 I set gettingBinaryImage to true when i hit
in the file cos this means that i am about to move to a binary part of the file.
Q3 newline is a string that = Environment.NewLine (\r\n),
I only use it when not getting binary image because they are hidden chars at the end of text, but i dont know if i should always use them. they are just to try to keep track of where i am in the file.
Q5 yep no probs.. need any bits explaining, let me know.
Going round in circles for the 4th day running.. so if its a bit messy sry in advance
Code:
using (StreamReader streamReader = new StreamReader(base.FileAndPath))
{
long fileLen = streamReader.BaseStream.Length;
while ((line = streamReader.ReadLine()) != null)
{
if (!gettingBinaryImage)
filePositionPointer += line.Length + newline.Length;
else
filePositionPointer += line.Length;
string[] words = line.Split(null);
switch (words[0])
{
case CIP3_PREVIEW_IMAGE: // moving into binary image so get the ascii text
binaryImageStartPosition = filePositionPointer + line.Length + newline.Length;
asciiString.Append(line + newline);
AddFileDataToArray( asciiString.ToString());
asciiString = null;
asciiString = new StringBuilder();
gettingBinaryImage = true;
break;
case CIP3_END_SEPERATIONS:
//need to get binary image here
binaryfinishPosition = filePositionPointer + line.Length + newline.Length;
testFileLength = streamReader. BaseStream.Position;
hexString = GetHexImage(binaryImageStartPosition, binaryfinishPosition);
asciiString.Append(line + newline);
AddFileDataToArray(hexString);
gettingBinaryImage = false;
break;
case CIP3_END_OF_FILE_COMMENT:
asciiString.Append(line + newline);
AddFileDataToArray(asciiString.ToString());
WriteTestFile();
break;
default:
if (!gettingBinaryImage)
{
if (line.Length > 0)
asciiString.Append(line + newline);
//AddFileDataToArray(hexString);
}
break;
}
}
}
I guess I should re emphasize what I am trying to do. I am going through an ascii file (no problem) I count my characters (don’t know if I should). I find the beginning of a binary image (CIP3_PREVIEW_IMAGE

that I need to convert back to hex data (no problem converting) . I try to find the end of the image so I carry on counting … I come to CIP3_END_SEPERATIONS: (“CIP3EndSeparation” in the file this is after the binary image) so I get the number of characters passed and I now call a function and pass the image start position and finish position so it will extract the binary data from the file which can then be converted to hex….. When I get all this data I will create a new file which will be duplicate of this one but with Hex data and not binary. Hope this is clearer?
Age is a consequence of experience