|
i am running my service on a computer and i want to know wheather a system is in logoff or login state?
r00d0034@yahoo.com
|
|
|
|
|
I'm trying to get a synchronous connection to a server using the various .NET stream classes. It seems that I can send a command to the server successfully, but nothing is returned (or the StreamReader returns before the data can be read off of the socket). Here's the psuedocode/real code :
static void Main(string[] args)
{
string newsServerName = "msnews.microsoft.com";
int newsServerPort = 119;
TcpClient newsServer;
try {
newsServer = new TcpClient();
newsServer.Connect( newsServerName, newsServerPort );
}
catch( SocketException e )
{
string error = "Failed to connect to " + newsServerName + " on port " + newsServerPort;
Console.WriteLine( error );
Console.WriteLine( e.Message );
return;
}
NetworkStream netStream;
StreamReader reader;
StreamWriter writer;
try {
netStream = newsServer.GetStream();
reader = new StreamReader( netStream );
writer = new StreamWriter( netStream );
if ( reader.Peek() > -1 ) {
while ( reader.Peek() > -1 ) {
Console.WriteLine( reader.ReadLine() );
}
}
string sendMessage = "LIST" + "\r\n";
Console.WriteLine( "Sending message." );
writer.WriteLine( sendMessage );
writer.Flush();
Console.WriteLine( "Waiting for response." );
while ( reader.Peek() > -1 ){
Console.WriteLine( reader.ReadLine() );
}
}
catch( Exception e ) {
Console.WriteLine( "Error talking with server." );
Console.WriteLine( e.Message );
}
}
The last while loop never writes anything out. At the very least I should get the response from the server. How can I make the StreamReader wait until there is data before trying to dump out? I know this can be done with plain Send and Recv on a Socket, but I would like to use the Stream* classes if possible.
greg
|
|
|
|
|
Try this:
string line;
while ( (line = reader.ReadLine()) != null && line != "." )
{
Console.WriteLine( line );
}
NB: .\r\n is the signal for the end of the data.
|
|
|
|
|
i am using process class for my work?
is there any why to get current running thread and its id ?and its associated hwnd?
what are standaredinput and standaredoutput properties?
is there any online example where these properties are used if yes plz provide link?
may i get currently active window hwnd of type HWND using HWNDLE property of Process?
r00d0034@yahoo.com
|
|
|
|
|
Hi Imran,
The code for
http://www.codeproject.com/useritems/popupkiller.asp
has some hints towards this.
deepak
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
This is a general windows dev question, I couldn't find it in the docs or google. How in C# do I get ahold of the windows temp directory location? You know, c:\winnt\temp, or if someone's logged in it's Documents and Settings\<username>\temp... etc etc.. Is this a good place to store temp. files, or should I use my application's install directory?
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
In WIN32, it is :
DWORD GetTempPath(
DWORD nBufferLength,
LPTSTR lpBuffer
);
Easy to interop.
You could as well use WIN32 ExpandEnvironmentStrings , passing %TMP% as parameter.
Or read the registry, etc.
Back to real work : D-25.
|
|
|
|
|
System.IO.Path.GetTempPath() will return the current temp directory.
You may want to look at isolated storage[^] instead, especially if your app will be running in a locked-down environment.
|
|
|
|
|
Well said!
public static string System.IO.Path.GetTempPath() {
StringBuilder local0;
uint local1;
string local2;
new EnvironmentPermission(1).Demand();
local0 = new StringBuilder(260);
local1 = Win32Native.GetTempPath(260, local0);
local2 = local0.ToString();
if (!(local1))
__Error.WinIOError();
return local2;
}
Back to real work : D-25.
|
|
|
|
|
Bah! You need Anakrino to tell you that? I can read it in IL!
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
David Stone wrote:
Bah! You need Anakrino to tell you that? I can read it in IL!
You asking for a slap.
you think ur soo cool wiv ur li'l IL book
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Nnamdi Onyeyiri wrote:
You asking for a slap.
Ah. You don't understand...it's an inside joke.
Nnamdi Onyeyiri wrote:
you think ur soo cool wiv ur li'l IL book
Yeah...that's me...I'm cool...I'm bad...uh-huh oh yeah!
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
David Stone wrote:
Ah. You don't understand...it's an inside joke.
Oh, maybe its that you dont understand how lightly that phrase is used here.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
|
I'm going to use System.IO.Path.GetTempPath() as richard_d suggested. My app is a desktop windows app so I dont think I'll need special storage.
thanks
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
I want to be able to create a program that will parse a flat file into an xml file that a typed dataset can read or parse the flat file into a custom generated typed dataset. Is this possbile and if so how would I use codedom, etc to get this result?
|
|
|
|
|
|
Search MSDN for Interop and API
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
I am writing a code generator that reads in a text file containing source code. The file is my template and it contains {1}, {2}... {n} items in it. I read the file into a string and then I interpolate those values using String.Format(string format, params object[] args). It seems to work fine as long as I don't have any squiggly braces in it ({}) other than the ones that I want to use for formatting (e.g. the {1}, {2}, etc values). It appears that String.Format is choking on the other braces in the code template. I get the exception 'System.FormatException - Input string was not in the correct format'. Does anyone know why this is and how to fix it? Does this makes sense?
Thanks in advance.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Escaping braces is achieved by doubling them. Example : string s = Stirng.Format("my number {{is}} {0}",45);
Back to real work : D-26.
|
|
|
|
|
Gracias!!!
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
hi,
consider using the System.Text.Stringbuilder class ( method AppendFormat ). it is much faster with these kind of string operations.
franz
|
|
|
|
|
HELLO
SIR WE ARE DOING WORD PROGRAMMING USING C SHARP, HAVE PROBLEM IN USING PROPERTIES , AFTER ADDING MSWORD.OLB .
THERE ARE SOME INTERFACES AND CLASSES AS WELL , BUT HAVE PROBLEM IN USING PROPERTIES.
Asim
|
|
|
|
|
WHAT IS THE PROBLEM YOU ARE HAVING? TELL ME NOW. WE HAVE WAYS OF MAKING YOU TALK.
Pete
Insert Sig. Here!
|
|
|
|
|
thanks sir
we eventually have been able to use these properties.thanks for offering some favoure.
now the problem is how to display a picture, i.e we want to open a word document and want to get some picture if any and then to show it, now this is where the problem is we have opened word and got the picture from it but now problem is how to show it.
this is how we got the paragraph from word doc ,
Word.Range rngtext = aDoc.Application.ActiveDocument.Paragraphs.Item(2).Range;
MessageBox.Show(rngtext.Text);
now how to get show the picture?
Asim
|
|
|
|