Click here to Skip to main content
15,867,750 members
Home / Discussions / C#
   

C#

 
GeneralRe: Mobile phone programs Pin
dan!sh 14-Oct-09 4:17
professional dan!sh 14-Oct-09 4:17 
GeneralRe: Mobile phone programs Pin
EliottA14-Oct-09 4:56
EliottA14-Oct-09 4:56 
AnswerRe: Mobile phone programs Pin
solomonope14-Oct-09 7:08
solomonope14-Oct-09 7:08 
QuestionUserControl and Collections in Designer Pin
cinias14-Oct-09 3:10
cinias14-Oct-09 3:10 
AnswerRe: UserControl and Collections in Designer Pin
Henry Minute14-Oct-09 3:41
Henry Minute14-Oct-09 3:41 
Questionbiometric sdk for hp ipaq pda Pin
solomonope14-Oct-09 2:30
solomonope14-Oct-09 2:30 
AnswerRe: biometric sdk for hp ipaq pda Pin
Richard MacCutchan14-Oct-09 3:07
mveRichard MacCutchan14-Oct-09 3:07 
QuestionGetting corrupt data from NetworkStream.Read Pin
JFord123414-Oct-09 1:34
JFord123414-Oct-09 1:34 
I've made a small app that downloads an XML file every one minute from a server. I have to use a Socket for it as I must write the HTTP headers myself.

The program works fine until it doesn't. Every few minutes the XML that's being downloaded is somewhat corrupt. When I open it I can see the XML with all the normal data, except that in random places there are always 4 random characters that are being inserted. When I use a packet sniffer I can see that the data being received is fine and that the chars aren't in the end or beginning of a packet - just in random places.

This is the loop I'm using to read the XML file:
file = File.Create("C:\\info.xml");
            bool isFirstPacket = true;

            byte[] buffer = new byte[1024];
            int bytesRead;

            while (true)
            {
                bytesRead = stream.Read(buffer, 0, 1024);
                if (bytesRead == 0)
                    continue;
                if (isFirstPacket)
                {
                    isFirstPacket = false;
                    int i = 0;
                    while (buffer[i] != 0x3c)
                    {
                        i++;
                    }
                    file.Write(buffer, i, bytesRead - i);

                }
                else if (buffer[bytesRead - 2] == 0x0d && buffer[bytesRead - 1] == 0x0a && buffer[bytesRead - 3] == 0x0a && buffer[bytesRead - 4] == 0x0d && buffer[bytesRead - 5] == 0x30)
                 {
                    file.Write(buffer, 0, bytesRead - 7);
                    file.Close();
                    break;
                }
                else
                {
                    file.Write(buffer, 0, bytesRead);
                }
            }
            file.Close();


Does anyone have a clue as to why this would happen? thanks.
AnswerRe: Getting corrupt data from NetworkStream.Read Pin
Richard MacCutchan14-Oct-09 3:20
mveRichard MacCutchan14-Oct-09 3:20 
GeneralRe: Getting corrupt data from NetworkStream.Read Pin
JFord123414-Oct-09 5:51
JFord123414-Oct-09 5:51 
QuestionWebservice and proxy Pin
Mogyi13-Oct-09 23:11
Mogyi13-Oct-09 23:11 
AnswerRe: Webservice and proxy Pin
Keith Barrow14-Oct-09 2:00
professionalKeith Barrow14-Oct-09 2:00 
GeneralRe: Webservice and proxy Pin
Mogyi14-Oct-09 2:15
Mogyi14-Oct-09 2:15 
AnswerRe: Webservice and proxy Pin
Hristo-Bojilov14-Oct-09 2:04
Hristo-Bojilov14-Oct-09 2:04 
GeneralRe: Webservice and proxy Pin
Mogyi14-Oct-09 2:17
Mogyi14-Oct-09 2:17 
QuestionOpening a named browser window from a windows application Pin
mSh198513-Oct-09 22:26
mSh198513-Oct-09 22:26 
QuestionAdding Data to datagridview [modified] Pin
ldsdbomber13-Oct-09 20:36
ldsdbomber13-Oct-09 20:36 
AnswerRe: Adding Data to datagridview Pin
OriginalGriff13-Oct-09 23:50
mveOriginalGriff13-Oct-09 23:50 
GeneralRe: Adding Data to datagridview Pin
ldsdbomber14-Oct-09 1:22
ldsdbomber14-Oct-09 1:22 
Questionwrite to a excel sheet that is already open Pin
ananya choudhury13-Oct-09 17:18
ananya choudhury13-Oct-09 17:18 
QuestionApp Communication via screen reads Pin
Rizean13-Oct-09 15:54
Rizean13-Oct-09 15:54 
QuestionVisual Studio integrated Source Control Pin
Expert Coming13-Oct-09 13:46
Expert Coming13-Oct-09 13:46 
AnswerRe: Visual Studio integrated Source Control Pin
Expert Coming13-Oct-09 15:26
Expert Coming13-Oct-09 15:26 
GeneralRe: Visual Studio integrated Source Control Pin
Not Active13-Oct-09 17:41
mentorNot Active13-Oct-09 17:41 
AnswerRe: Visual Studio integrated Source Control Pin
Kevin Marois14-Oct-09 5:38
professionalKevin Marois14-Oct-09 5:38 

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.