Tuesday, May 26, 2009
Writing to a file with C#
It had been a while since I had to write a file with .Net, I don't think I really had done it since vanilla ASP. As I remember it wasn't hard then and it really hasn't changed to much since then. See below for code on how to check to see if the directory exists, and then how to actually create and write to a file.
Check to see if path exists if not create it
if(!System.IO.Directory.Exists(path))
System.IO.Directory.CreateDirectory(path);
Create the file
public void WriteFile(string fileText, string fileName){
string fullPath = "<Where ever your path is>"
try{
FileInfo file = new FileInfo(fullPath);
StreamWriter stream = file.CreateText();
stream.WriteLine(fileText);
stream.Close();
}catch(Exception ex){
//handle exception
}
}
Labels: .NET
posted by Tom Becker at
|

Wednesday, May 20, 2009
Big League Chew, round 2
So this game was kind of a nail bitter. It really did come right down to the wire with the winning run on first. We ended up winning 12-9, but it was touch and go there in the last inning.
We started off really well, we had a 10-0 lead coming out of the first inning, and then I don't know what happened we stopped hitting and they started. I really don't know how else to explain it. I think there were a couple of iffy calls made by the umpire but that really doesn't explain us pissing away a 10-0 lead. Personally I walked once (first inning) and grounded out in the second, and then we subbed me out before I could bat in the third.
I think we got cocky and over confident with our lead and just started playing bad fundamentals. We had some good plays with our shortstop and 3rd baseman snagging some line drives, but lets just say that if we had to play one more inning the outcome may have been a bit different
No game next week because of Memorial day, but in two weeks we play The Pros.
Labels: Softball
posted by Tom Becker at
|

Tuesday, May 19, 2009
Unable to attach debugger process in Visual Studio
Today I had to debug a web service that was running locally and in the same solution where the project that I am working on. Before I seem to remember just automatically stepping into the web service while debugging, but that was in Visual Studio 2005, so it could be different with 2003. So in order to do this you need to attach the worker process to the debugger so it can load all the symbols and whatnot, so it will catch at breakpoints and you can step through line by line
So to attach a new process for the debugger to what you go to Debug -> Processes and then choose from the list and click attach. In my case this was the .Net worker process aspnet_wp.exe. This did not work for me right off, and it seems that many other people are having the same problem. I kept getting that wonderfully generic MS message that says "Unable to attach process" and that was it, no other help. In this case it can be just a simple oversight.
There is a worker process for each version of .Net that you have running. I was careless when I set up the web service in IIS and I had it running under the 2.0 worker process instead of 1.1, which is fine in general since everything is backwards compatible, but in order to debug you need to make sure you have everything matching up and choosing the right worker process for your app.
Labels: Visual Studio
posted by Tom Becker at
|

Thursday, May 14, 2009
Been gone for a while
I know I have been gone for a while, and haven't been posting very much, but I promise I am still out here. I have been really busy the past month or so. Getting married, buying a house, and all that. Still don't have internet at the house yet, that is why there hasn't been any softball postings (we are 4-0 I think, whoohoo). And I have been on the bench since the first of the year, and that is why there hasn't been any .Net or SQL postings. But that, hopefully, will change soon as I have started on a new contract.
I am now working for Intrepid Services here in Richmond, and will be working on some cool projects, so once I get into those I will start posting some code up here again.
Labels: random
posted by Tom Becker at
|
