By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,140 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Problem when using Reader Class Help needed!

P: n/a
Let's start off by saying I'm a noob to .Net but here's my problem.
I have many files, all with the same structure.
I know the structure, It was written in some version of C++.
Because it seem to be a null terminated or serialized file
using text readers reads only until the first null and thinks it has
reached the EOF.
Using the BinaryReader and the BaseStream.Position I know where I'm at
in the file. However, most of the file is numeric and presenting no
dificulties, but one field is text and I cannot get it to display in a
Datagrid other than numeric. The numeric values of the text field do
not corrolate to ansi, ascii, or anything else I can determine.
Here is a small sampling of the code that wrote the file:, ios::binary);
if (
return false;*)&Version, sizeof(unsigned int));
if (Version != DB_VERSION) { // fixme
return false;
Id << in;*)&totalX, sizeof(unsigned int));*)&totalY, sizeof(unsigned int));*)&totalZ, sizeof(unsigned int));*)&total1, sizeof(unsigned int));
through position 580 then the text part is added
const bool Namespace::Write(const char* path, const char* name)
const unsigned int currentVersion = DB_VERSION;
ofstream out;
ifstream in;
char filename[MAX_PATH + MAX_ID_STRING+1];
int i, j, n;
char namesUsed[3][MAX_NAME+1];
unsigned int nameCount[3];
bool done, newFile;
int mostIdx[3] = {-1,-1,-1};
unsigned int topNum;
int topIdx;
unsigned int Version;
n = (unsigned)strlen(path);
if (n > MAX_PATH)
strncpy(filename, path, n);
steamId.ToStr(filename + n);
strcat(filename, ".some extension");
// replace ':' with '-' in filename
for (i=n, n=strlen(filename); i < n; i++) {
if (filename[i] == ':')
filename[i] = '-';
// Read file and store the namesUsed and nameCount variables, ios::binary);
newFile = ( || in.peek() == EOF);
for(i=0; i<3; i++) {
namesUsed[i][0] = 0;
nameCount[i] = 0;
Any Help would be Greatly appreciated. I have been working on this
issue for two weeks, using many google searches and samples.

Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.