... Home Contact

Krzysztof Koźmic's blog

You're doing it wrong.


Show appreciation: My Amazon.com Wish List

Me@Twitter

    Currently reading

    Article Categories

    Archives

    Post Categories

    MyPersonal

    Syndication:

    June 2007 Entries

    Converting custom Strings to DateTime

    One of projects I'm currently working on involves reading a file produced by other tool, that has rather unusual way of storing a date and time. For example 1st of July 2007, 14:00:00 would be stored as 20070701T140000Z (colors added for emphasis). Using Convert.ToDateTime(string) or DateTime.Parse(string) throws FormatException. Parsing manually (splitting string and parsing its substring to ints to create DateTime object from them) is not very elegant solution. There is however static method DateTime.ParseExact(string, string, IFormatProvider). First parameter is encoded DateTime, second is pattern, and third can be null. How to create pattern you can learn from this msdn article....

    Compare paths from the end in C#

    Today at work, a colleague came to me with quite interesting problem. He needed to find out first common directory for two given paths starting from the end. For example, for given paths like: c:\documents and settings\some user\my files\projects\project1\initialFiles\somefiles\ and d:\ My Projects\project1\ChangedFiles\MyFiles\ It would return 'project1'. I was surprised to find out that neither System.IO.Path, nor System.IO.Directory allows you to that. Here's simple solution I created for him. public static string FindLastCommonParentFolder(string path1, string path2) { ...

    Not working ReSharper 3 and disabled menus issue resolved... kind of

    As I see, many visitors from Google come to my blog after running query like "ReSharper 3 menus disabled", "ReSharper 3 not working" and similar. Well, I have good news and bad news for you. Good news is, I installed ReSharper once again and it works now. The bad news however is, that I reinstalled Visual Studio first, so I'm aware that it may not be acceptable solution for some people. I needed to install VSIP Factory and my GAX kept throwing errors, so I got mad, uninstalled the whole thing (meaning Visual Studio and all things on top of...

    Technical books and blogs

    I've just listen to new .NET Rocks podcast with Don Box, and Chris Sells about, well - about myriad of things, but main topic was technical books and ways of learning new technologies. They mostly focused on shrinking market of books, as blogs become more popular and people gain their knowledge from blogs more and more and less from books. However, I thing there is one difference that they barely touched, although it's the most important one. There will be place for books, and not only as a way to get the zen of a technology, but as a...

    Regionerate - very cool plugin for VS and #Develop

    Today I found (via Roy's post) very nice plugin that works with both Visual Studio and SharpDevelop. It's called Regionerate, is free and is developed by Omer Rauchwerger. As Omer wrote: Regionerate (pronounced ri-jeh-neh-rate) is a new open-source tool for developers and team leaders that allows you to automatically apply layout rules on C# code.  I feel very happy to find it, since it does exactly this, what I wanted for a long time, and it's something that neither Refactor! Pro, nor ReSharper allows you to do. At the moment it's in its infancy (current version is 0.6beta) but even...

    Bug in UTF8Encoding class?

    As I work at translation/localization company, I deal a lot with files with different code pages, and strange formats. While working on a project recently I stumbled across strange thing, that I think is a bug in UTF8Encoding class. I was reading a plain text file, encoded with Windows 1252 code page, using FileStream and StreamReader. Everything was working fine, but I noticed that when reading one particular file, program produced strange results. TO be precise when reading file with string like this:   Results looked like this: StreamReader ate up umlaut characters. When file was saved as UTF8...

    ReSharper 3.0 final... still doesn't work

    Congratulations to JetBrains for pulling out new release of ReSharper. I hoped that it would resolve problem I had with beta release, but unfortunately it does not. Situation looks exactly like it was with beta release. ReSharper installer claims that installation was successful, but was it really?   Still, all options are grayed out, and that menu, and ReSharper logo are actually only signs of ReSharper's presence. Add-in manager in Visual Studio even doesn't list it . I reported the issue to JetBrains, but their investigation of the problem ended with one question after which they closed the case as 'Cannot Reproduce' the following...

    Acropolis team on Dot Net Rocks

    Microsoft project Acropolis is creating a lot of buzz lately. Actually more than I would have expected, which is a good thing. I am only surprised that there are no non-Microsoft samples yet. When Silverlight (WPF/E back then) was first introduced, there were some really stunning samples made the very next day. I guess it's just because, Silverligh mostly about what you see, while Acropolis is about what you don't see. Guys from Acropolis team have been recently very busy blogging, and posting new samples. As a matter of fact they've produced so much content, and I have been so busy...

    About web browsers and Apple Safari for windows in particular

    Are you, dear reader one of those people who downloaded Apple Safari 3 beta for windows? I am, and for sure I will not switch to Safari. I am pretty happy with my current configuration. Primarily I use Firefox with lots of extensions, and I can't imagine not having it. It's basically first application I install on clear system. It may not be the fastest (actually for most sites it's the slowest of all browsers I use), it may eat up lots of RAM and processor cycles, but user experience blows all other browsers away. To make things clear. Bare Firefox,...

    Install SCSF v2 without having VB solution installed

    When Smart Client Software Factory v2 came out, I couldn't install it on my machine, because I didn't have VB solutions installed with Visual Studio. P&P team published a solution to this. I didn't check it yet, but it should work, although it looks like a lot of hassle to get it to work. Technorati tags: SCSF, P&P, Visual Studio, VB

    Why not support SharpDevelop?

    In his great post about ORMs, EF, eSQL and data access in general, Sahil Malik wrote something about Visual Studio 2005, that I would like to comment on. The VS2005 IDE is stuck in a rather unfortunate monopolistic situation. There is no incentive for any other company to create a better IDE because the IDE costs some serious $$$ to create, and MSFT gives it away for peanuts. It is impossible to compete with such a model, so I don't expect google or adobe to come out with a Visual Studio.NET that is better.  And I...

    Updating Controls in Windows Forms

    How often do you find yourself writing code like this: Code Snippet string[] files = GetFiles(path); filesListView.BeginUpdate(); for (int i = 0; i < files.Length; i++) { //possibly something more ...

    Get to running application from ROT

    While cleaning old projects I found this one, that I wrote some time ago, and decided to post here, because it took me long time to figure it out, and although at the end it didn't work (to clarify things, not because there is something wrong with it, because if how that particular app registered its instances to ROT) I don't want to go through it again.   IBindCtx bindCtx; Dictionary<string, Namespace.Application> items = new Dictionary<string, Namespace.Application>();...

    Acropolis Hello World

    Yesterday I gave Orcas Visual Studio 2008 beta 1 another try. At first, when it came out, I deleted it, due to free hard disc space shortage, and it's annoying errors. I actually downloaded it (which took me almost entire day on my 1.5Mb wire) solely to play with new Acropolis bits. I don't have anything interesting to share yet, since I finished installation and VM Setup quite late, but I must say that my first impression is very nice. I’m a little bit confused by the Visual Studio Designer, that is like nothing I know from CAB and SCSF,...

    Acropolis to replace CAB/SCSF

    I like CAB and SCSF, I really do, although I'm by no means expert at it, I used it in one, not so big project so far, when I moved over the hard part (getting used to naming conventions and getting to know how the things are organized and how they fit together) I really liked it. When I learned about Acropolis I got the feeling that Microsoft just said: "This is the way you are supposed to do smart client applications", and that it means good bye to CAB. Glenn Block just said it clear and loud: With the announcement of Acropolis, we currently...

    Visual Studio 2008 Shell and Sharp Develop for Applications

    The think that drew attention in last couple of days is the new Visual Studio 2008 Shell. What it is, is basically bare bones core of Visual Studio that Microsoft is going do release (for free I believe) , so that you could build your own VS-like Apps on top of that. Nice idea isn't it? That's something that Eclipse has been allowing for some time now, and as I just learned, Sharp Develop too. I found this, almost one year old post from Sharp Develop dev team, announcing Sharp Develop for Applications, that utilizes the same idea. Technorati tags:...

    Microsoft vs Jamie Cansdale's TestDriven.NET case is getting famous

    It seems that Jamie Cansdale's case is attracting attention not only in .NET world. Today I noticed that biggest Polish IT news portal dobreprogramy.pl published a news about it entitled "Microsoft sends out lawyers to community". It's good that case is getting famous, because it may trigger wider debate about vague software licenses. Technorati tags: Jamie Cansdale, TestDriven.NET, Microsoft, Work Around Technical Limitations

    My 3 cents about ALT.NET; do it Microsoft way vs do it the right way

    David Laribee coined the term ALT.NET. What it means, and why it's going to be the_hot_word? David basically explained it in 4 points: What does it mean to be to be ALT.NET? In short it signifies: You’re the type of developer who uses what works while keeping an eye out for a better way. You reach outside the mainstream to adopt the best of any community: Open Source, Agile, Java, Ruby, etc. You’re not content with the status quo. Things can always be better expressed, more elegant and simple, more mutable, higher quality, etc. You know tools are great, but...

    What kind of developer are you

    I found this test via Mads Kristensen's blog. My result: Your programmer personality type is:DHTB You're a Doer.You are very quick at getting tasks done. You believe the outcome is the most important part of a task and the faster you can reach that outcome the better. After all, time is money.You like coding at a High level.The world is made up of objects and components, you should create your programs in the same way.You work best in a Team.A good group is better than the sum of it's parts. The only thing better than a genius programmer is...

    Get ready for Acropolis!

    I've been concerned that CAB since its 1.0 release seemed to be a dead project, although there certainly was a lot to do. P&P team focused on other things like software factories, leaving CAB as it was. I guess we now have the answer why. Microsoft announced (and released 1st CTP of) project Acropolis. It looks like CAB for WPF on steroids, and may be the-hot-thing in desktop development. There's a crappy quality screencast up on this site. Basically project is announced but still I couldn't find many information about it. Is it going to be integrated with Orcas, or...

    Feedburner Feed

    Mostly to get some statistics, I moved my direct feed to Feedburner. I am impressed by the wealth of options they have there. I played with it a bit, added email subscription if someone prefers it over RSS/Atom. If you find any errors in it or have any suggestions, please let me know :) Technorati tags: Feedburner, rss, atom, feed

    ReSharper 3.0 beta... gone?

    It seems like I may not be able to play with ReSharper after all, at least not until I find a solution to this: After installing ReSharper 3.0 beta, onto previous build, ReSharper seems to be disabled. First, I had Two ReSharper menus, both with all options disabled like here. After I Removed ReSharper, Rolled back my VS settings to state before installing ReSharper and installing it once again, Nothing changed except for the fact that instead of two dead menus I have one. Any solution? (other than reinstalling VS ). [UPDATE] It seems I'm not the only one having this problem after installing beta version....

    ReSharper

    I probably shouldn't even admit but: 'I haven't been using ReSharper'... I mean, never before. And before you ask - no, I haven't been on a remote island for last X years. I actually knew that there was such a tool, I simply didn't realize how great it is! It was Jean-Paul S. Boodhoo's series of screencasts on Demystifying Design Patterns, on DNR TV, that made me like - 'Wow, that's a great tool he's using' (he actually does more ReSharper magic that actual coding in these screencasts , but that's OK - J.P - great series by the way,...

    Working around technical limitation to get spellchecking in Windows Live Writer

    It seems that I'm not the only one having problems with getting this much praised inline spellchecking to work. As it turned out I was right assuming that the problem is me having non-English windows. Alex, posted nice workaround for this in his comment to Oren's post. I checked - it works. Thanks Alex. Technorati tags: Windows Live Writer, Working around technical limitation, enable spellchecking

    No spellchecker in Windows Live Writer beta 2

    While publishing previous post (first one using beta 2 of WLW) I noticed one feature that was there in beta 1 and now apparently has been removed: spellchecker! I have no idea why they would remove such usefull feature, especially, that it worked very well in beta 1. I guess I'll have to do copy/paste to and from OpenOffice Writer to check my spelling, since I'm neither native english speaker, nor good speller . [UPDATE] While reading David Hayden's post on WLW I noticed, that one of the features in beta 2 is Inline spell checking What the...? Why...

    Krzysztof Cwalina's great lecture available to download

    You know who Krzysztof Cwalina is - right? The Framework Design guy. He recently gave a lecture on that topic at Microsoft Research center, and now he made it available for download. I haven't seen it whole yet (it's iver 3h long!) but i strongly recomend it. Get it here, and if you didn't already - subscribe to Krzysztof's blog: here.   Technorati tags: Krzysztof Cwalina, .NET, .NET framework, design, lecture, Microsoft

    Partial Methods - the most useless c# 3.0 feature?

    I feel puzzled. On the one hand, I KNOW that Anders, Wes, and other people working on c# 3.0 language/compiler, are very smart people, yet I fail to see solid arguments why extend c# 3.0 with partial methods. Wes tried twice explain this feature, and I have read both posts twice, just to make sure I didn't lose the gist of it. To quote him: Partial methods are methods that enable lightweight event handling.  Here is an example declaration: partial class C{  static partial void M(int i);} The idea is that you have partial method declaration (notice the...

    Windows Live Writer and SubText incompatibility issues

    Microsoft released 2nd beta of Windows Live Writer yesterday. That's good, I used 1st beta to publish my posts and I tried to publish previous post with the new version but there seems to be some API incompatibility issue between WLW and SubText, since when I tried to publish it, it Subtext threw this exception: Server Error 0 Occurred Illegal Characters Found    at Subtext.Framework.Text.HtmlHelper.HasIllegalContent(String s)   at Subtext.Framework.Data.DatabaseObjectProvider.FormatEntry(Entry e, Boolean UseKeyWords)   at Subtext.Framework.Data.DatabaseObjectProvider.Create(Entry entry, Int32[] categoryIds)   at Subtext.Framework.Entries.Create(Entry entry)   at Subtext.Framework.XmlRpc.MetaWeblog.newPost(String blogid, String username, String password, Post post, Boolean publish) I guess I'll stick to beta 1 for now....

    How to embed custom control in ToolStrip

    ToolStrip is very useful container control, but it has it's default set of controls you can put onto it. What if you wanted to have, say DateTimePicker, or some totally custom control you have made? You can inherit it from ToolStripItem, override some methods and properties, but there is a much quicker way, if you don't need any custom behaviour. To illustrate this i created simple form with ToolStrip, and I embeded DateTimePicker into it, as you can se below (code follows) As you can see, all the magic that happens is thanks to ToolStripControlHost class. private void...