Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
QuestionFileStream runtime issues (Updated) [modified] Pin
Mikey_H15-Aug-09 14:21
Mikey_H15-Aug-09 14:21 
AnswerRe: FileStream runtime issues Pin
Luc Pattyn15-Aug-09 14:38
sitebuilderLuc Pattyn15-Aug-09 14:38 
GeneralRe: FileStream runtime issues [modified] Pin
Mikey_H15-Aug-09 14:59
Mikey_H15-Aug-09 14:59 
AnswerRe: FileStream runtime issues Pin
riced15-Aug-09 23:09
riced15-Aug-09 23:09 
GeneralRe: FileStream runtime issues Pin
Mikey_H15-Aug-09 23:22
Mikey_H15-Aug-09 23:22 
AnswerRe: FileStream runtime issues (Updated) Pin
riced16-Aug-09 0:18
riced16-Aug-09 0:18 
GeneralRe: FileStream runtime issues (Updated) Pin
Mikey_H16-Aug-09 1:44
Mikey_H16-Aug-09 1:44 
GeneralRe: FileStream runtime issues (Updated) Pin
riced16-Aug-09 2:32
riced16-Aug-09 2:32 
I can't reproduce this problem so don't know how to solve it.
There is the possibility that it is just a MessageBox issue.

I created a form as I said before with button and multiline textbox then added this code as click handler.
private void button1_Click(object sender, EventArgs e)
{
   //FileInfo m_FileInfo = new FileInfo("C:\\Playpen\\poker_utf8.txt");
   FileInfo m_FileInfo = new FileInfo("C:\\Playpen\\poker.txt");
   long fileLen = m_FileInfo.Length;
   byte[] buffer = new byte[fileLen];

   using (FileStream stream = new FileStream(m_FileInfo.FullName, FileMode.Open, FileAccess.Read))
   {
      // Read data from file to the buffer
      for (long i = 0; i != fileLen; i++)
         buffer[i] = (byte)stream.ReadByte();
   }

   string data = new System.Text.UTF8Encoding(true).GetString(buffer);
   long strLen = data.Length;
   MessageBox.Show("Len of buffer: " + fileLen.ToString() + "\r\nLen of data  : " + strLen.ToString());
   textBox1.Text = data;
   MessageBox.Show(data); // Shows incomplete file
}


Set a breakpoint on 'string data = ...' and then step through it.
The data string does contain whole of file. And this is confirmed by the textbox contents.
I created poker.txt by copying your text and doing multiple pastes using Notepad. poker_utf8.txt is the same file saved as UTF-8.
(You get a slight discrepancy in lengths when using poker_utf8 because the UTF-8 has a three byte BOM as a prefix.)

Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis

GeneralRe: FileStream runtime issues (Updated) Pin
Mikey_H16-Aug-09 12:48
Mikey_H16-Aug-09 12:48 
QuestionReading letters from an Image in C# Pin
Sumit_Ghosh15-Aug-09 12:41
Sumit_Ghosh15-Aug-09 12:41 
AnswerRe: Reading letters from an Image in C# Pin
Henry Minute15-Aug-09 13:24
Henry Minute15-Aug-09 13:24 
QuestionWeb Browser(C# + other .NET technologies) Pin
abhifanatic15-Aug-09 10:12
abhifanatic15-Aug-09 10:12 
AnswerRe: Web Browser(C# + other .NET technologies) Pin
Saksida Bojan15-Aug-09 10:29
Saksida Bojan15-Aug-09 10:29 
QuestionC# IP Scanner Pin
nhqlbaislwfiikqraqnm15-Aug-09 10:06
nhqlbaislwfiikqraqnm15-Aug-09 10:06 
AnswerRe: C# IP Scanner Pin
Saksida Bojan15-Aug-09 10:31
Saksida Bojan15-Aug-09 10:31 
GeneralRe: C# IP Scanner Pin
nhqlbaislwfiikqraqnm15-Aug-09 10:52
nhqlbaislwfiikqraqnm15-Aug-09 10:52 
GeneralRe: C# IP Scanner Pin
Saksida Bojan15-Aug-09 18:57
Saksida Bojan15-Aug-09 18:57 
GeneralRe: C# IP Scanner Pin
nhqlbaislwfiikqraqnm15-Aug-09 21:55
nhqlbaislwfiikqraqnm15-Aug-09 21:55 
GeneralRe: C# IP Scanner Pin
Saksida Bojan15-Aug-09 22:02
Saksida Bojan15-Aug-09 22:02 
AnswerRe: C# IP Scanner Pin
mrcooll15-Aug-09 22:43
mrcooll15-Aug-09 22:43 
GeneralRe: C# IP Scanner Pin
nhqlbaislwfiikqraqnm15-Aug-09 22:50
nhqlbaislwfiikqraqnm15-Aug-09 22:50 
QuestionDownload Free E books Pin
naveensky15-Aug-09 7:03
naveensky15-Aug-09 7:03 
AnswerRe: Download Free E books Pin
Hristo-Bojilov15-Aug-09 7:07
Hristo-Bojilov15-Aug-09 7:07 
AnswerRe: Download Free E books Pin
0x3c015-Aug-09 7:36
0x3c015-Aug-09 7:36 
QuestionNeed to learn ROUND decimal digits Pin
M Riaz Bashir15-Aug-09 4:46
M Riaz Bashir15-Aug-09 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.