It’s end of January 2012 by now, but I decided to share some stats on what was going on with this blog in 2011. If you fancy reading my stuff (is there anybody?
) you might find it interesting.
Let’s get down to the business:
- only 3 posts that year
busy? lazy? …?
- nevertheless, I was observing constant interest growth (more and more vistst, by Google Analytics):
- 196,717 Visits (+45% comparing to 2010)
- 178,770 Unique Visitors (+46% comparing to 2010)
- 222,258 Pageviews (+42% comparing to 2010)
- most popular post: C#, decimal.toString(), and how to get rid of trailing zeros – 17,302 pageviews
What if you need to undelete a file or bunch of files that at some point have been deleted from TFS? Naive option would be to get the content of the file, copy it, create a new file, and paste the copied content to just created file. Of course, this is not a good option because history of changes to the file(s) will be lost.
Continue reading ‘Visual Studio TFS: How to undelete file(s)’
Published on
January 9, 2012 in
.net and c#.
Tags: .net, c#.
How to get service name listening at specific port in C#? What you have as input is only two pieces of information: host name and the port number the service is listening at.
Solution
Apparently, .NET does not provide such feature so one needs to stretch a bit to get the answer. What I can suggest (I’m far from saying it’s good approach, though) is to get the name in two steps:
- Use
netstat -a -o and parse the output (ouch!) to get ID of the process (PID) that is listening at given port number
- Perform a WMI call to get the name of the service:
SELECT Name FROM Win32_Service where ProcessId = PID
Following this will give you what you want, but to be honest any time I need to parse output to get some information I feel anxious… This is the first place in the code where errors can be introduced.
If there is/are better/safer way(s) to retrieve service name having the host name and port it’s listening at, please share it.