simple TcpClient echo client/server example

I was trying to help a beginner dev that (like many early on) wanted to tackle an irc bot as their first project.  They had apparently googled for C# irc and came across this code.  Now, having spent a couple of my college years running my own irc server on EFNet, I’m not really inclined to…

4

Pretty-printing valid xml snippet

It’s proven useful in a couple of places, and it’s pretty small and self-documenting.  I had written this mainly to look at my VS settings file in a nicer way since it saves with a minimum of whitespace.   private static string ToPrettyXml(string xml) {     XmlDocument doc = new XmlDocument();     try     {…

1

IEnumerable<T> and interleaving of I/O with CPU

Not all problems lend themselves to this, but as a general suggestion, if you’re handling T[] or {I,}List<T> or ArrayList or the like of items (especially ones coming from I/O sources – files, network, etc.) with a single pass, you should consider (as with all perf, measure, measure, measure!) going the piecemeal route with IEnumerable<T>…

3

starting a process on a remote machine

Uses your existing credentials, of course, but I wanted to pass along in case others could use this: ManagementClass processClass = new ManagementClass(“\\\\” +     remoteServer + “\\root\\CIMV2:Win32_Process”); ManagementBaseObject inParams = processClass.GetMethodParameters(“Create”); inParams[“CommandLine”] = program; ManagementBaseObject outParams = processClass.InvokeMethod(“Create”, inParams, null); Console.WriteLine(“Started process id {0} on server {1}”,     outParams[“ProcessId”], remoteServer);   Also, Juanya Williams…

4

System.IO api’s, temp files, closing, and the right tool for the job

I have a couple of blog posts that are in stewing nicely, but they’re not really ready yet and I want to get them as right as possible on the first posting to try and make them an authoritative reference I can use later (see suzcook/cbrumme/raymondc/etc.) – however, in the mean time there’s been a small…

1

the static class in C# 2.0 is better than you think!

Fully unrelated to Hatteras, but a C# developer whohas been playing around with the beta was attempting to point out (incorrectly that the “static” modifier to a class was just syntax sugar and no better than making a private default constructor that was never called from the class itself (perhaps one that just did a…

2

pushd – autofs on Windows that i never knew about and other ramblings

It had been on my blog todo list for awhile, but Buck beat me to it pushd works nicely for creating that mapping for you that’s nice and trasient – when you popd, it goes away.  This makes it excellent not only for interactive use, but incredible for scripts when you need to deal with…

0

.NET 2.0 meta-highlights

Junfeng has posted a great list of NET 2.0 highlights that is definitely worth a read. I think I’m not alone in maintaining lists of things that would have been great to have while tackling former problems.  In my case, those happen to mainly be Java apps, but regardless of the framework, they’re nice to have now.  Some are…

2

Guess who starts Monday? Jim Hugunin!

Ever since reading JasonZ’s post about it, I’ve been very interested in IronPython.  Part of it was ActiveState’s largely failed (from a perf perspective at least) attempt at Python for .NET, but my interest was reinforced when I found out about Jim being the father of Jython.  I had learned about and used Jython at…

1

what to call an option to dump to stdout?

I’m working on our “view” command where you can view older versions of files as you want – as an example “h view foo.cs;C123” would view the version of foo.cs at changeset 123 “h view $/bar/ack.cs;Lfoo” would view that server item with the version pointed to by the “foo” label.  One of the things we’ve decided…

30