long line truncated on vista 2048

  • Thread starter Thread starter pmo
  • Start date Start date
P

pmo

I'm writing to a logfile in My Documents.
I'm want to write a rather long line approximately 2200 chars.

On XP it works as expected but on Vista only the first 2048 chars are
written.
Does anyone know why and how to get around it?

I tried both StreamWriter,File.AppendAllText and File.WriteAllText
 
I'm writing to a logfile in My Documents.
I'm want to write a rather long line approximately 2200 chars.

On XP it works as expected but on Vista only the first 2048 chars are
written.
Does anyone know why and how to get around it?

I tried both StreamWriter,File.AppendAllText and File.WriteAllText

It seems unlikely that this is a problem with Vista. How are you
viewing the file? How are you getting the data in the first place?

Do you have a short but complete program which demonstrates the
problem?

Jon
 
Jon said:
It seems unlikely that this is a problem with Vista. How are you
viewing the file?

I'm viewing the file in the same app. I'm writing a datafile with
default text-tokens in my application. Later (without restarting the
app) I read in the tokens again and the last 15 tokens was missing and
the last found was corrupt.

To find out what happened I wrote the data to the logfile too, I
wanted to make sure that the data was all there. It wasn't.
How are you getting the data in the first place?

The default dataset is statically stored in the application.

Do you have a short but complete program which demonstrates the
problem?

Not yet
I'll try that later. But your answer seems to indicate that I wount be
able to make one.

/pmo
 
Hi,


I do not think that it has anything todo with Vista, maybe it's notepad who
has the issue (if you use notepad to see the file)

In any case it's a warning that there will be some editors that will have
issues with such a long line.
 
I'm viewing the file in the same app. I'm writing a datafile with
default text-tokens in my application. Later (without restarting the
app) I read in the tokens again and the last 15 tokens was missing and
the last found was corrupt.

Have you tried looking at the file in a simple text editor? How does
the app read in the tokens?
To find out what happened I wrote the data to the logfile too, I
wanted to make sure that the data was all there. It wasn't.

And how did you view the log file?
The default dataset is statically stored in the application.

Are you able to debug into the application to see if it's definitely
there at the point of writing it?
Not yet
I'll try that later. But your answer seems to indicate that I wount be
able to make one.

I suspect not - but it's worth a try :)

Jon
 
pmo said:
I'm writing to a logfile in My Documents.
I'm want to write a rather long line approximately 2200 chars.

On XP it works as expected but on Vista only the first 2048 chars are
written.
Does anyone know why and how to get around it?

I tried both StreamWriter,File.AppendAllText and File.WriteAllText

What is the exact content of the file you're writing? Are there other,
shorter lines that are present and which are not truncated? Or is there
just this one long line? Or is the long line at the end of the file?

If any of the latter, are you sure that you are correctly flushing and
closing the stream? Failing to do so would be a common way for data to
not get completely written to a file (but I would expect AppendAllText
and WriteAllText to correctly handle this, so who knows?)

Generally speaking, if you can write text to a file at all, the text
will always be written correctly. So either the text isn't actually
being written to the file, or you are not using a correct means to
determine whether the text is actually in the file or not.

Pete
 
Hi,

I do not think that it has anything todo withVista, maybe it's notepad who has the issue (if you use notepad to see the file)

In any case it's a warning that there will be some editors that will have issues with such a long line.

Sorry for not answering sooner.
It has nothing to do with the editor, the data simply isn't there.
My application looks for the datafile at startup, if it's not there it
writes out a default dataset. Simply a lot of strings from an static
array.

Later it reads back in the data. I check to see if the number of
tokens is the same as the array length. It's not. This coupled with
what I see in notepad (in Vista) leads me to believe that the data is
not all getting to the file. (Plus it works flawless in XP)

So something mucks up the print to file... me or vista?

/pmo
 
Sorry for not answering sooner.
It has nothing to do with the editor, the data simply isn't there.
My application looks for the datafile at startup, if it's not there it
writes out a default dataset. Simply a lot of strings from an static
array.

Later it reads back in the data. I check to see if the number of
tokens is the same as the array length. It's not. This coupled with
what I see in notepad (in Vista) leads me to believe that the data is
not all getting to the file. (Plus it works flawless in XP)

So something mucks up the print to file... me or vista?

Well, that's impossible to tell without some code. I have suspicions
around not closing FileStreams/StreamWriters etc, but it sounds like
it should be fairly easy to reproduce in a test app.

Jon
 
What is the exact content of the file you're writing? Are there other,
shorter lines that are present and which are not truncated? Or is there
just this one long line? Or is the long line at the end of the file?

If any of the latter, are you sure that you are correctly flushing and
closing the stream? Failing to do so would be a common way for data to
not get completely written to a file (but I would expect AppendAllText
and WriteAllText to correctly handle this, so who knows?)

Generally speaking, if you can write text to a file at all, the text
will always be written correctly. So either the text isn't actually
being written to the file, or you are not using a correct means to
determine whether the text is actually in the file or not.

Pete
Sorry for the delayed reply.

It's just one long line at this point in the data file, in the logfile
its one of many shorter lines.
I tried using streamwriter so that I could do a proper close after
writing, did not help. Whats pussling is that it breaks inside a
token. The write statement is as can be.

string text = join(_defaultTokens, _separator);
File.WriteAllText(path, text, Encoding.Default);


I'm going to install visual studio on a vista box so that I can run it
through the debugger and look at 'text'

/pmo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top