|
George_George wrote: Your code is magic.
George_George wrote: What is the root cause of my original issue? And why your code can fix?
It was probably in the File/Resource you were reading. But because you need to read the whole file, ReadToEnd actually does not seem to stop at \0. This is probably by design.
My code fixes it as creating a string, will make sure it is only up to the first \0. After that, the rest is never considered.
To add: It is interesting that you found this. I have never come across it, but at least I am aware of it now (thanks).
|
|
|
|
|
Thanks leppie!
Where in your code trims the string with ends \0?
regards,
George
|
|
|
|
|
\0 is the equivalent of null. Strings used to be null terminated but are not anymore (at least in .NET) however, the new String method is probably designed to stop reading on an null character in a string. I wonder, however, about the memory allocation. It is possible that the entire string is stored in memory, including the nulls but only the non-null portion is workable. (happens in C sometimes)
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Thanks Ennis!
Does your reply answers why leppie's code trims endding \0?
regards,
George
|
|
|
|
|
George_George wrote: What is the root cause of my original issue?
I had a think about this. I suspect you are reading a binary file as a text file.
|
|
|
|
|
Thanks leppie!
I am reading from HttpListenerContext.Request.InputStream. Just send one XML file from a client, and my code read from another end.
1.
In this process, why do you think I experienced "reading a binary file as a text file", which causes \0 at the end?
2.
Do you have a scenario to reproduce this issue?
regards,
George
|
|
|
|
|
Hello
yesterday i have asked a question for a connection between a client and a server using a c# application,and that client should send a file to the server.
Someone tell me to use the tcp/ip.
But the client and the server are connected only trough internet.So does this tcp/ip run,Do someone have some other idea??
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
The ip part stands for 'internet protocol'. I guess you didn't bother to look it up.
If it were me, if the web were involved, I'd have a webservice on the server, and send using that.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
when i create a service on the server, how can i connect to that web service from the client.
Note : there is not a web site or an ftp. I mean by a server a pc connected to the internet only( ).
So can i instanciate that service from the client.
dghdfghdfghdfghdgh
|
|
|
|
|
If the two machines are just connected to the web and the server is not an actual server on the internet, then you probably want to go back to creating a TCP/IP connection. How does the client discover the server at all ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am using visual studio 2003. My application is a window application and i am using C#. I want to put double click event for each row in the datagrid.
Can anyone help me please.
|
|
|
|
|
If there isn't one, you can catch a single click, store the time it occured and on the next click see if they were close enough together to make a double click.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hehe, so you get blamed for the lack of functionality. I sometimes wonder what goes through the minds of some characters.
|
|
|
|
|
Christian Graus wrote: you can catch a single click, store the time it occured and on the next click see if they were close enough together to make a double click.
I guess then page need to post back two times, right ? How about hooking JS double click event and raising postback manually ? I haven't tried it, but a wild guess.
BTW, don't know why you got down voted.
|
|
|
|
|
Aren't there data grids in winforms ? If this is an ASP.NET question, it's in the wrong forum.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Oops, I am sorry. I forgot which forum I am in. Sorry.
|
|
|
|
|
*grin* It did occur to me that the question is ASP.NET, but I act dumb until it's clear, and assume the question is in the right forum.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
what is the basic difference between evemts and function.
i know events execute a handler and function are user defined.
but unable to understad the difference
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Pankaj Garg wrote: i know events execute a handler and function are user defined.
correct
Pankaj Garg wrote: but unable to understad the difference
It's what you said. An event is something you can subscribe to, to be informed when something happens. The event will call functions, but most functions are not attached to events.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Can u reply to this issue[^]
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
I'm sorry, I don't know the first thing about Active Directory
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
anyone who knows all the corner of the face book please tell me what is it? in which kind of situation one should use face book. what is the advantage of using face book.please tell me in detail.
Thanks
tbhattacharjee
|
|
|
|
|
Gosh - google is broken where you live ?
I have no idea what this has to do with C# ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi.
I wanted to remove Vista security notification balloon that pops up when you deactivate UAC (User access control).
I need to do this in an application written in C#, I can easily do this in a cmd, but it does not seem to work in C#.
I write this in the CMD:
REG DELETE "HKCR\CLSID\{FD6905CE-952F-41F1-9A6F-135D9C6622CC}" /f
So I created this C# code:
CreateProcess("reg.exe", @"DELETE \"HKCR\CLSID\{FD6905CE-952F-41F1-9A6F-135D9C6622CC}\" /f");
Create process creates a new process with reg.exe as an application and the delete as argument.
That does not work. Any ideas?
|
|
|
|
|
Yeah, try writing some code that accesses the registry directly instead of trying to duplicate your command line code.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|