<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Wed, 10 Jun 2026 03:57:35 +0000</lastBuildDate>
    <item>
      <title>(Python) Getting shovel to work in windows so python methods can be run like individual executables - pckujawa</title>
      <link>https://snipplr.com/view/66267/getting-shovel-to-work-in-windows-so-python-methods-can-be-run-like-individual-executables</link>
      <description>&lt;p&gt;I had hear about a method to run a method like an executable, with the arguments being passed in from the commandline. Apparently, Ruby has this with the Rake project. Well, Python has it with [Shovel](http://devblog.seomoz.org/2012/03/shovel-rake-for-python). Only the instructions didn't work for me on windows, so I had to create a batch script to call `shovel` correctly.&#13;
&#13;
So here's my setup. I installed shovel using `easy_install shovel`, which placed it in my python scripts folder (C:\Python27\Scripts, which is in my PATH). I created 'shovel.bat' (see source) in the same folder. So now I can call `shovel` from anywhere and it will call my batch file, passing the parameters into shovel.&#13;
&#13;
For completeness, here is my working directory structure (note the subfolder called shovel):&#13;
&#13;
	D:.&#13;
	â”‚   song log.log&#13;
	â”‚   Untitled_10.mp3&#13;
	â”‚   Untitled_11.mp3&#13;
	â”‚   Untitled_2.mp3&#13;
	â”‚   Untitled_3.mp3&#13;
	â”‚   Untitled_4.mp3&#13;
	â”‚   Untitled_5.mp3&#13;
	â”‚   Untitled_6.mp3&#13;
	â”‚   Untitled_7.mp3&#13;
	â”‚   Untitled_8.mp3&#13;
	â”‚   Untitled_9.mp3&#13;
	â”‚&#13;
	â””â”€â”€â”€shovel&#13;
	        tasks.py&#13;
&#13;
My python script is incomplete but can be run by shovel using `shovel tasks.extractSongInfo "log file name.log"` from the directory above the 'shovel' directory. Here's the script:&#13;
&#13;
&#13;
	from shovel import task&#13;
	&#13;
	@task&#13;
	def extractSongInfo(logFile):&#13;
	    """Given a log file with lines like&#13;
	"{date}	INFO	 Currently playing - Song: {songName} - Artist: {artist} - Length: {numSeconds}"&#13;
	return a collection of extracted info."""&#13;
	    opId = "Extracting song info" # operation ID&#13;
	    print opId&#13;
	    print 'Done: ' + opId&lt;/p&gt;</description>
      <pubDate>Sun, 22 Jul 2012 07:44:22 UTC</pubDate>
      <guid>https://snipplr.com/view/66267/getting-shovel-to-work-in-windows-so-python-methods-can-be-run-like-individual-executables</guid>
    </item>
    <item>
      <title>(C#) Get the MAC (Physical) address from a device at the specified IP address - pckujawa</title>
      <link>https://snipplr.com/view/54687/get-the-mac-physical-address-from-a-device-at-the-specified-ip-address</link>
      <description>&lt;p&gt;This is about the simplest way I've found. See [this](http://stackoverflow.com/questions/1092463/getting-the-mac-address-of-the-remote-host) and [this](http://stackoverflow.com/questions/1092379/want-to-get-mac-address-of-remote-pc/1092392#1092392) at StackOverflow for more info.&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 08:50:09 UTC</pubDate>
      <guid>https://snipplr.com/view/54687/get-the-mac-physical-address-from-a-device-at-the-specified-ip-address</guid>
    </item>
    <item>
      <title>(C#) Add the Console as a TraceListener (to have Trace messages treated as Console output) - pckujawa</title>
      <link>https://snipplr.com/view/38306/add-the-console-as-a-tracelistener-to-have-trace-messages-treated-as-console-output</link>
      <description>&lt;p&gt;This is particularly useful for unit testing, but you could do it anywhere in your code.&lt;/p&gt;</description>
      <pubDate>Wed, 04 Aug 2010 03:00:55 UTC</pubDate>
      <guid>https://snipplr.com/view/38306/add-the-console-as-a-tracelistener-to-have-trace-messages-treated-as-console-output</guid>
    </item>
    <item>
      <title>(C#) Calculate a CRC32 like the one used in zip files - pckujawa</title>
      <link>https://snipplr.com/view/37249/calculate-a-crc32-like-the-one-used-in-zip-files</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 14 Jul 2010 03:33:44 UTC</pubDate>
      <guid>https://snipplr.com/view/37249/calculate-a-crc32-like-the-one-used-in-zip-files</guid>
    </item>
    <item>
      <title>(C#) Check if a string can be represented as ASCII - pckujawa</title>
      <link>https://snipplr.com/view/35806/check-if-a-string-can-be-represented-as-ascii</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 17 Jun 2010 02:52:04 UTC</pubDate>
      <guid>https://snipplr.com/view/35806/check-if-a-string-can-be-represented-as-ascii</guid>
    </item>
    <item>
      <title>(C#) Encrypting passwords and other sensitive information in .NET - pckujawa</title>
      <link>https://snipplr.com/view/35568/encrypting-passwords-and-other-sensitive-information-in-net</link>
      <description>&lt;p&gt;If you want to serialize a password in some custom object you are working with, create another member that is the encrypted bytes and serialize/deserialize that.&#13;
&#13;
For simply encrypting/decrypting a file, you can use [System.IO.File.Encrypt](http://msdn.microsoft.com/en-us/library/system.io.file.encrypt.aspx)/Decrypt.&lt;/p&gt;</description>
      <pubDate>Mon, 07 Jun 2010 15:18:34 UTC</pubDate>
      <guid>https://snipplr.com/view/35568/encrypting-passwords-and-other-sensitive-information-in-net</guid>
    </item>
    <item>
      <title>(C#) ListView with re-ordering through drag and drop - pckujawa</title>
      <link>https://snipplr.com/view/33427/listview-with-reordering-through-drag-and-drop</link>
      <description>&lt;p&gt;Microsoft has acknowledged (see URL) that the lack of this functionality is an error. The extended control code below adds reordering to a ListView. It works with multiple items as well as single items.&#13;
&#13;
See also:&#13;
[http://www.codeproject.com/KB/list/dragdroplistviewreorder1.aspx](http://www.codeproject.com/KB/list/dragdroplistviewreorder1.aspx).&lt;/p&gt;</description>
      <pubDate>Wed, 28 Apr 2010 11:39:54 UTC</pubDate>
      <guid>https://snipplr.com/view/33427/listview-with-reordering-through-drag-and-drop</guid>
    </item>
    <item>
      <title>(C#) Sending emails (particularly with gmail and google apps for domains) - pckujawa</title>
      <link>https://snipplr.com/view/32573/sending-emails-particularly-with-gmail-and-google-apps-for-domains</link>
      <description>&lt;p&gt;For both gmail and gApps, use smtp.gmail.com on port 25 with SSL and NetworkCredentials.&#13;
&#13;
Neither can send email to their own address, but they can send to other addresses.&#13;
&#13;
[NLog](http://nlog-project.org/) has [an example](http://nlog-project.org/wiki/Using_NLog_with_GMail) of how to automatically send emails in order to log info from an app.&lt;/p&gt;</description>
      <pubDate>Wed, 21 Apr 2010 10:44:27 UTC</pubDate>
      <guid>https://snipplr.com/view/32573/sending-emails-particularly-with-gmail-and-google-apps-for-domains</guid>
    </item>
    <item>
      <title>(C#) Byte Swapping Structs For Conversion From Big To Little Endian (Byte Order) - pckujawa</title>
      <link>https://snipplr.com/view/32482/byte-swapping-structs-for-conversion-from-big-to-little-endian-byte-order</link>
      <description>&lt;p&gt;See the URL for my question and answer on StackOverflow.&lt;/p&gt;</description>
      <pubDate>Tue, 20 Apr 2010 16:03:34 UTC</pubDate>
      <guid>https://snipplr.com/view/32482/byte-swapping-structs-for-conversion-from-big-to-little-endian-byte-order</guid>
    </item>
    <item>
      <title>(C#) Add index numbers to each row header in a DataGridView - pckujawa</title>
      <link>https://snipplr.com/view/31065/add-index-numbers-to-each-row-header-in-a-datagridview</link>
      <description>&lt;p&gt;`w_Dgv` is the name of the DataGridView control.&lt;/p&gt;</description>
      <pubDate>Wed, 07 Apr 2010 12:15:42 UTC</pubDate>
      <guid>https://snipplr.com/view/31065/add-index-numbers-to-each-row-header-in-a-datagridview</guid>
    </item>
    <item>
      <title>(C#) Converting MethodInfo into a delegate instance to improve performance - pckujawa</title>
      <link>https://snipplr.com/view/29683/converting-methodinfo-into-a-delegate-instance-to-improve-performance</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 12 Mar 2010 10:13:43 UTC</pubDate>
      <guid>https://snipplr.com/view/29683/converting-methodinfo-into-a-delegate-instance-to-improve-performance</guid>
    </item>
    <item>
      <title>(C#) Persisting values in an application between executions and upgrades (.NET) - pckujawa</title>
      <link>https://snipplr.com/view/29302/persisting-values-in-an-application-between-executions-and-upgrades-net</link>
      <description>&lt;p&gt;Read the [best article on the subject - Exploring Secrets of Persistent Application Settings](http://www.devx.com/dotnet/Article/33944/1954) - and then the following links if desired. (Note, I recommend reading [this forum post about settings not being upgraded](http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/790980e8-eb89-492c-976b-4f93dc7c1caf/).)&#13;
&#13;
It might help to understand [What is app.config for?](http://stackoverflow.com/questions/1431742/what-is-app-config-for)&#13;
&#13;
Also of note: [Saving out a Form's Size and Location using the Application Settings feature](http://blogs.msdn.com/rprabhu/archive/2005/11/28/497792.aspx). Be sure to read the first couple of comments as well.&#13;
&#13;
Lastly, if you are interested in import/export functionality, check out [my post on the subject](http://stackoverflow.com/questions/2389290/how-to-load-a-separate-application-settings-file-dynamically-and-merge-with-curre).&lt;/p&gt;</description>
      <pubDate>Thu, 04 Mar 2010 17:08:30 UTC</pubDate>
      <guid>https://snipplr.com/view/29302/persisting-values-in-an-application-between-executions-and-upgrades-net</guid>
    </item>
    <item>
      <title>(C#) Basic insert and select commands for SQLite in .NET - pckujawa</title>
      <link>https://snipplr.com/view/29247/basic-insert-and-select-commands-for-sqlite-in-net</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 03 Mar 2010 17:38:15 UTC</pubDate>
      <guid>https://snipplr.com/view/29247/basic-insert-and-select-commands-for-sqlite-in-net</guid>
    </item>
    <item>
      <title>(C#) Hex edit control for .NET GUI - pckujawa</title>
      <link>https://snipplr.com/view/28343/hex-edit-control-for-net-gui</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 15 Feb 2010 13:35:13 UTC</pubDate>
      <guid>https://snipplr.com/view/28343/hex-edit-control-for-net-gui</guid>
    </item>
    <item>
      <title>(C#) .NET 4.0 and System.Threading.Tasks - pckujawa</title>
      <link>https://snipplr.com/view/28339/net-40-and-systemthreadingtasks</link>
      <description>&lt;p&gt;See URL.&lt;/p&gt;</description>
      <pubDate>Mon, 15 Feb 2010 11:38:15 UTC</pubDate>
      <guid>https://snipplr.com/view/28339/net-40-and-systemthreadingtasks</guid>
    </item>
    <item>
      <title>(C#) Obfuscating .NET code so as to hide implementation details from public view (using BabelObfuscator) - pckujawa</title>
      <link>https://snipplr.com/view/28194/obfuscating-net-code-so-as-to-hide-implementation-details-from-public-view-using-babelobfuscator</link>
      <description>&lt;p&gt;If you weren't already aware, you can use a product like [Reflector.NET](http://www.red-gate.com/products/reflector/) to see all of the source code (that's right, the code) of a .NET assembly (DLL, EXE, etc). This is a real problem when your code is proprietary, especially when you might have security implementations in the code. Thus, there is often a need to hide the implementation details - enter obfucation.&#13;
&#13;
There is a [article on and list of obfuscators from C# 411](http://www.csharp411.com/net-obfuscators/) which explains the situation better. From my research, I decided to settle on the free and open source [Babel Obfuscator](http://code.google.com/p/babelobfuscator/). Part of the decision process was seeing it in action, which is especially easy when you install the [Babel add-in for Reflector](http://www.jasonhaley.com/blog/post/2009/08/18/ReflectorBabel-Addin.aspx).&#13;
&#13;
Once you've decided that Babel is for you, the code below automates the process when added to the post-build event of your assembly. The parameters and settings are up to you, but this baseline should do everything you'll need.&lt;/p&gt;</description>
      <pubDate>Thu, 11 Feb 2010 13:59:34 UTC</pubDate>
      <guid>https://snipplr.com/view/28194/obfuscating-net-code-so-as-to-hide-implementation-details-from-public-view-using-babelobfuscator</guid>
    </item>
    <item>
      <title>(C#) Get the network interface card (NIC) from a known MAC address (and get the IP addresses on that NIC) - pckujawa</title>
      <link>https://snipplr.com/view/28193/get-the-network-interface-card-nic-from-a-known-mac-address-and-get-the-ip-addresses-on-that-nic</link>
      <description>&lt;p&gt;The code shows how to take a known MAC (e.g. "00:00:00:11:22:33") and locate the NIC which has that MAC. Note that the built-in MAC class for .NET is called PhysicalAddress (in System.Net.NetworkInformation). PhysicalAddress.Parse can take a string, so long as it has only numbers or numbers and dashes (-). We normally use colons (:) instead of dashes, so that's why I do a .Replace().&#13;
&#13;
The last part of the code retrieves the IP Addresses associated with the selected NIC.&lt;/p&gt;</description>
      <pubDate>Thu, 11 Feb 2010 13:48:57 UTC</pubDate>
      <guid>https://snipplr.com/view/28193/get-the-network-interface-card-nic-from-a-known-mac-address-and-get-the-ip-addresses-on-that-nic</guid>
    </item>
    <item>
      <title>(C#) Bind a socket (including UdpClient and TcpClient) to a local network interface card (NIC) - pckujawa</title>
      <link>https://snipplr.com/view/28192/bind-a-socket-including-udpclient-and-tcpclient-to-a-local-network-interface-card-nic</link>
      <description>&lt;p&gt;If you are using a UdpClient or TcpClient, you have access to the internal Socket which either type uses. Unfortunately, if you try to Bind that Socket to a local Endpoint (IPAddress and Port), you will probably get a SocketException. The solution I found is to create the Socket independently, then assign that instance to the UdpClient (as shown in the code) or TcpClient (changing the Socket parameters, of course).&lt;/p&gt;</description>
      <pubDate>Thu, 11 Feb 2010 13:41:21 UTC</pubDate>
      <guid>https://snipplr.com/view/28192/bind-a-socket-including-udpclient-and-tcpclient-to-a-local-network-interface-card-nic</guid>
    </item>
    <item>
      <title>(C#) Enumerate all controls and sub-controls in a windows form - pckujawa</title>
      <link>https://snipplr.com/view/27564/enumerate-all-controls-and-subcontrols-in-a-windows-form</link>
      <description>&lt;p&gt;Found in the above URL. Requires extension methods (C# 3.0+).&lt;/p&gt;</description>
      <pubDate>Tue, 02 Feb 2010 11:03:02 UTC</pubDate>
      <guid>https://snipplr.com/view/27564/enumerate-all-controls-and-subcontrols-in-a-windows-form</guid>
    </item>
    <item>
      <title>(C#) Embed reference dlls (assemblies) in an executable (exe) or one dll in .NET - pckujawa</title>
      <link>https://snipplr.com/view/27194/embed-reference-dlls-assemblies-in-an-executable-exe-or-one-dll-in-net</link>
      <description>&lt;p&gt;Use [ILMerge](http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx) (and the [GUI](http://ilmergegui.codeplex.com/), if you prefer) or the other solution presented in the url. Or [.NETz](http://www.madebits.com/netz/). [SmartAssembly](http://smartassembly.com) also provides a nice commercial solution.&lt;/p&gt;</description>
      <pubDate>Wed, 27 Jan 2010 16:14:16 UTC</pubDate>
      <guid>https://snipplr.com/view/27194/embed-reference-dlls-assemblies-in-an-executable-exe-or-one-dll-in-net</guid>
    </item>
    <item>
      <title>(C#) Communicate between different applications and processes (Inter-Process Communication) - pckujawa</title>
      <link>https://snipplr.com/view/26722/communicate-between-different-applications-and-processes-interprocess-communication</link>
      <description>&lt;p&gt;Read the article, it's good. They use named pipes for IPC.&lt;/p&gt;</description>
      <pubDate>Tue, 19 Jan 2010 15:56:33 UTC</pubDate>
      <guid>https://snipplr.com/view/26722/communicate-between-different-applications-and-processes-interprocess-communication</guid>
    </item>
    <item>
      <title>(C#) Working with Unix epoch in .NET (changing between DateTime and time since epoch) - pckujawa</title>
      <link>https://snipplr.com/view/26339/working-with-unix-epoch-in-net-changing-between-datetime-and-time-since-epoch</link>
      <description>&lt;p&gt;Tentative source shows conversion to/from microseconds.&lt;/p&gt;</description>
      <pubDate>Tue, 12 Jan 2010 18:57:30 UTC</pubDate>
      <guid>https://snipplr.com/view/26339/working-with-unix-epoch-in-net-changing-between-datetime-and-time-since-epoch</guid>
    </item>
    <item>
      <title>(C#) Simple XML parsing using LINQ (create an anonymous or real object from XML data) - pckujawa</title>
      <link>https://snipplr.com/view/24923/simple-xml-parsing-using-linq-create-an-anonymous-or-real-object-from-xml-data</link>
      <description>&lt;p&gt;See the URL.&lt;/p&gt;</description>
      <pubDate>Wed, 16 Dec 2009 18:57:43 UTC</pubDate>
      <guid>https://snipplr.com/view/24923/simple-xml-parsing-using-linq-create-an-anonymous-or-real-object-from-xml-data</guid>
    </item>
    <item>
      <title>(C#) Automatically showing a wait cursor to indicate a long operation is occurring - pckujawa</title>
      <link>https://snipplr.com/view/24851/automatically-showing-a-wait-cursor-to-indicate-a-long-operation-is-occurring</link>
      <description>&lt;p&gt;Great way to show the user that something is happening without too much tedious work. As simple to use as putting the following code in Form_Load:&#13;
&#13;
	AutoWaitCursor.Cursor = Cursors.WaitCursor;&#13;
	AutoWaitCursor.Delay = new TimeSpan(0, 0, 0, 0, 25);&#13;
	// Set the window handle to the handle of the main form in your application &#13;
	AutoWaitCursor.MainWindowHandle = this.Handle;&#13;
	AutoWaitCursor.Start();&#13;
&#13;
(From the site)      &#13;
It can be extremely tiresome to have to continually remember to set and unset the wait cursor for an application. If an exception occurs you have to remember to add a try finally block to restore the cursor, or if you popup a message box you must remember to change the cursor first otherwise the user will just sit there thinking the application is busy! These are just a few of the many irritations that I have tried to solve with the class below.&#13;
&#13;
The class below automatically monitors the state of an application and sets and restores the cursor according to whether the application is busy or not. All thatâ€™s required are a few lines of setup code and your done (see the example in the class header). If you have a multithreaded application, it won't change the cursor unless the main input thread is blocked. Infact you can remove all of your cursor setting code everywhere!&lt;/p&gt;</description>
      <pubDate>Tue, 15 Dec 2009 17:08:25 UTC</pubDate>
      <guid>https://snipplr.com/view/24851/automatically-showing-a-wait-cursor-to-indicate-a-long-operation-is-occurring</guid>
    </item>
    <item>
      <title>(C#) Logging in .NET with NLog (default config file, catch all exceptions and route to logger, ...) - pckujawa</title>
      <link>https://snipplr.com/view/24560/logging-in-net-with-nlog-default-config-file-catch-all-exceptions-and-route-to-logger-</link>
      <description>&lt;p&gt;[NLog](http://nlog-project.org) is an awesome, simple logging solution for .NET. In the code below, there is an example entry into app.config (there are other methods for doing NLog config files, but I have found that this one works with ClickOnce deployments). There is also a snippet for catching and logging all exceptions in a WinForms application and one for a WPF application.&#13;
&#13;
I also have a [question on stackoverflow](http://stackoverflow.com/questions/4091606/most-useful-nlog-configurations) with a lot of useful NLog configuration answers.&lt;/p&gt;</description>
      <pubDate>Thu, 10 Dec 2009 12:33:48 UTC</pubDate>
      <guid>https://snipplr.com/view/24560/logging-in-net-with-nlog-default-config-file-catch-all-exceptions-and-route-to-logger-</guid>
    </item>
    <item>
      <title>(C#) Parsing information from an XML source (elements, nodes, attributes) using XPath - pckujawa</title>
      <link>https://snipplr.com/view/24528/parsing-information-from-an-xml-source-elements-nodes-attributes-using-xpath</link>
      <description>&lt;p&gt;The code is run in [LINQPad](http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;ved=0CAsQFjAA&amp;url=http%3A%2F%2Fwww.linqpad.net%2F&amp;ei=exUgS-a-KZOotgOs39T9CQ&amp;usg=AFQjCNFw-ZpPkP4je7u9udiur5Wg5us7tQ&amp;sig2=gA-_2y2xnTKzK2A9CVxXfg), which is where the Dump extension method comes from. You can pretend that it just outputs ToString. The input file for this snippet looks like so:&#13;
&#13;
	&lt;configuration&gt;&#13;
	  &lt;userSettings&gt;&#13;
	    &lt;HawkConfigGUI.Properties.Settings&gt;&#13;
	      &lt;setting&gt;&#13;
	        &lt;value&gt;testfpga&lt;/value&gt;&#13;
	      &lt;/setting&gt;&#13;
	      &lt;setting&gt;&#13;
	        &lt;value&gt;test&lt;/value&gt;&#13;
	      &lt;/setting&gt;&#13;
	    &lt;/HawkConfigGUI.Properties.Settings&gt;&#13;
	  &lt;/userSettings&gt;&#13;
	&lt;/configuration&gt;&#13;
&#13;
The output of the snippet is &#13;
&#13;
    FpgaFilePath =&gt; testfpga&#13;
    FirmwareFilePath =&gt; test&#13;
&#13;
So the snippet pulls out an attribute from the 'setting' element and the content (text between tags) of the 'value' sub-element.&lt;/p&gt;</description>
      <pubDate>Wed, 09 Dec 2009 16:23:52 UTC</pubDate>
      <guid>https://snipplr.com/view/24528/parsing-information-from-an-xml-source-elements-nodes-attributes-using-xpath</guid>
    </item>
    <item>
      <title>(C#) Persisting data using XML config files in WinForms (saving and restoring user and application data) - pckujawa</title>
      <link>https://snipplr.com/view/24482/persisting-data-using-xml-config-files-in-winforms-saving-and-restoring-user-and-application-data</link>
      <description>&lt;p&gt;References: [msdn blog](http://blogs.msdn.com/youssefm/archive/2010/01/21/how-to-change-net-configuration-files-at-runtime-including-for-wcf.aspx), [devX](http://www.devx.com/dotnet/Article/41639/0/page/1)&#13;
&#13;
The .NET framework provides XML configuration files (in the Properties-&gt;Settings area of a C# project or in app.config) which make it easy to bind and save/restore data between application executions. I want to take it one step further and allow the user to save and restore multiple versions of these config files, rather than just relying on the last-entered data.&#13;
&#13;
To get a file with any saved user settings, do this:  &#13;
&#13;
    internal static void Export(string settingsFilePath)&#13;
    {&#13;
        Properties.Settings.Default.Save();&#13;
        var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);&#13;
        config.SaveAs(settingsFilePath);&#13;
    }&#13;
&#13;
The ConfigurationUserLevel setting is important; it determines whether you get the file you see in Settings.settings or the file which has the user's custom data.&#13;
&#13;
(See example output file in source, as it won't show up correctly here.)&#13;
&#13;
To import the settings in a file, you can use the Import method below. [EDIT: This is the old method which only works for settings persisted as strings. The Import code in the Source window is much better and more robust. I'm just leaving this in for reference.]&#13;
&#13;
    internal static void Import(string settingsFilePath)&#13;
    {&#13;
        if (!File.Exists(settingsFilePath))&#13;
        {&#13;
            throw new FileNotFoundException();&#13;
        }&#13;
&#13;
        var appSettings = Properties.Settings.Default;&#13;
        try&#13;
        {&#13;
            // Open settings file as XML&#13;
            var import = XDocument.Load(settingsFilePath);&#13;
            // Get the &lt;setting&gt; elements&#13;
            var settings = import.XPathSelectElements("//setting");&#13;
            foreach (var setting in settings)&#13;
            {&#13;
                string name = setting.Attribute("name").Value;&#13;
                string value = setting.XPathSelectElement("value").FirstNode.ToString();&#13;
&#13;
                try&#13;
                {&#13;
                    appSettings[name] = value; // throws SettingsPropertyNotFoundException&#13;
                }&#13;
                catch (SettingsPropertyNotFoundException spnfe)&#13;
                {&#13;
                    _logger.WarnException("An imported setting ({0}) did not match an existing setting.".FormatString(name), spnfe);&#13;
                }&#13;
            }&#13;
        }&#13;
        catch (Exception exc)&#13;
        {&#13;
            _logger.ErrorException("Could not import settings.", exc);&#13;
            appSettings.Reload(); // from last set saved, not defaults&#13;
        }&#13;
    }&#13;
&#13;
References:  &#13;
[My question on StackOverflow](http://stackoverflow.com/questions/1869628/how-to-use-net-configuration-files-app-config-settings-settings-to-save-and-r)   &#13;
&#13;
http://articles.techrepublic.com.com/5100-10878_11-1044975.html  &#13;
&#13;
http://chiragrdarji.wordpress.com/2008/09/25/how-to-change-appconfig-file-run-time-using-c/  &#13;
&#13;
http://msdn.microsoft.com/en-us/library/system.configuration.configuration.aspx  &#13;
&#13;
http://stackoverflow.com/questions/132544/net-configuration-app-config-web-config-settings-settings  &#13;
&#13;
[Saving Settings in .NET 2.0 Apps](http://www.ddj.com/windows/187002743)&lt;/p&gt;</description>
      <pubDate>Tue, 08 Dec 2009 18:24:37 UTC</pubDate>
      <guid>https://snipplr.com/view/24482/persisting-data-using-xml-config-files-in-winforms-saving-and-restoring-user-and-application-data</guid>
    </item>
    <item>
      <title>(C#) Collection of .NET FAQs (catch all exceptions, UML, file associations, shutdown/restart, etc) - pckujawa</title>
      <link>https://snipplr.com/view/24271/collection-of-net-faqs-catch-all-exceptions-uml-file-associations-shutdownrestart-etc</link>
      <description>&lt;p&gt;65. Framework Tips General&#13;
	WinForms FAQ Home&#13;
   65.1 	Is it possible to turn off strong name validation for an assembly?&#13;
   65.2 	How can I catch an exception on a program wide basis?&#13;
   65.3 	Can I generate UML diagrams from C# code?&#13;
   65.4 	Does .Net support "deprecation" as in Java?&#13;
   65.5 	Can .NET applications run on non Microsoft Platforms?&#13;
   65.6 	Can I play audio and video files using .NET?&#13;
   65.7 	Can I create file associations with .NET?&#13;
   65.8 	Is there any way to Shutdown/Restart Windows using .NET?&#13;
   65.9 	How can I Invoke a private interface implementations of an instance using reflection?&#13;
   65.10 	How can I adjust the version number for multiple projects without changing every AssemblyInfo.cs file constantly?&#13;
   65.11 	How do I launch IE or any other process from code?&#13;
   65.12 	How do I pre-JIT an assembly to native code during installation?&#13;
   65.13 	How do I get the install directory for the version of the runtime that is loaded in the current process?&#13;
   65.14 	How to retrieve the assembly version, name, etc. contained in the "AssemblyInfo.cs", from inside the running app?&#13;
   65.15 	Is there a way to access private and protected members of a class instance?&#13;
   65.16 	In VB.NET how do I access the runtime type object of a specified type from it's type name?&#13;
   65.17 	How do I print a document using .NET?&lt;/p&gt;</description>
      <pubDate>Fri, 04 Dec 2009 10:41:53 UTC</pubDate>
      <guid>https://snipplr.com/view/24271/collection-of-net-faqs-catch-all-exceptions-uml-file-associations-shutdownrestart-etc</guid>
    </item>
    <item>
      <title>(C#) Binding an enum to a control (such as a ComboBox or DataGridView) with a custom string for each enum value - pckujawa</title>
      <link>https://snipplr.com/view/23615/binding-an-enum-to-a-control-such-as-a-combobox-or-datagridview-with-a-custom-string-for-each-enum-value</link>
      <description>&lt;p&gt;When you want to put the values of an enumeration into a ComboBox or similar control, there is no obvious or easy way to customize the text displayed. &#13;
&#13;
[UPDATE] The best method I've found is to use a custom TypeConverter. I haven't worked out all the intricacies, but the code below works for combo/listboxes and datagridviews, and I imagine that it would work with all IComponents.&#13;
&#13;
One method below uses the System.ComponentModel.DescriptionAttribute to create a nice description of the enum value and then reads those values using reflection and an extension method (requires .NET 3.5 - see the references for alternatives). Once those values are read, they are put in a Dictionary in order to act as the DataSource for a ComboBox (named w_wifiSecurityIO in the example). &#13;
&#13;
Unfortunately, attributes (to my knowledge) cannot access resources, so the first method does not allow for localization. To overcome this challenge, I have used a Dictionary&lt;string,&gt; as the control's Tag and then use the SelectedItem.ToString as the lookup for the enum value selected (works with multiple selections and Flags enums as well, e.g. in a CheckedListBox). The second method uses a Dictionary&lt;string,&gt; for the DataSource, sets the DisplayMember and ValueMember properties, then retrieves using the SelectedValue property.&#13;
&#13;
(Since the initialization code is only called once, and there are only a few enum values, the performance hit for using reflection is negligible. Even if it were noticeable, it might still be warranted when compared to other methods of customizing the displayed text.)&#13;
&#13;
The third method comes from the answer to a [StackOverflow question about the subject](http://stackoverflow.com/questions/1415140/c-enums-can-my-enums-have-friendly-names/1415460#1415460) and uses a simple extension method that allows for localization.&#13;
&#13;
Another method is [enumeration classes](http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/08/12/enumeration-classes.aspx).&#13;
&#13;
(Used in RedBird::Hawk.)&#13;
&#13;
References:&#13;
[msmvps.com](http://msmvps.com/blogs/deborahk/archive/2009/07/10/enum-binding-to-the-description-attribute.aspx)&#13;
[codeproject](http://www.codeproject.com/KB/cs/enumdatabinding.aspx)&#13;
[blogs.msdn](http://blogs.msdn.com/abhinaba/archive/2005/10/21/483337.aspx)&#13;
[local ms help](ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_system/html/7f153948-1284-313b-1f33-a6ed0d817322.htm) (DescriptionAttribute Class)&lt;/p&gt;</description>
      <pubDate>Mon, 23 Nov 2009 14:52:51 UTC</pubDate>
      <guid>https://snipplr.com/view/23615/binding-an-enum-to-a-control-such-as-a-combobox-or-datagridview-with-a-custom-string-for-each-enum-value</guid>
    </item>
    <item>
      <title>(C#) Isolated Storage in .NET (Reading, Writing, and Deleting a File; Checking Available Space) - pckujawa</title>
      <link>https://snipplr.com/view/23409/isolated-storage-in-net-reading-writing-and-deleting-a-file-checking-available-space</link>
      <description>&lt;p&gt;Code taken from the video in the URL.&lt;/p&gt;</description>
      <pubDate>Thu, 19 Nov 2009 13:10:42 UTC</pubDate>
      <guid>https://snipplr.com/view/23409/isolated-storage-in-net-reading-writing-and-deleting-a-file-checking-available-space</guid>
    </item>
    <item>
      <title>(C#) Visual Studio .NET Controls for Taking IP Address and MAC Address Info as Inputs - pckujawa</title>
      <link>https://snipplr.com/view/22421/visual-studio-net-controls-for-taking-ip-address-and-mac-address-info-as-inputs</link>
      <description>&lt;p&gt;This snippet builds on my last snippet regarding [User input validation in Visual Studio .NET using MaskedTextBoxes and an ErrorProvider](http://snipplr.com/view/22419/user-input-validation-in-visual-studio-net-using-maskedtextboxes-and-an-errorprovider/).&#13;
&#13;
Using a MaskedTextBox (MTB) works well for a MAC address because the length of the input is always the same: six octets (a.k.a. bytes) with hexadecimal input (0-9A-F) with or without colon (:) or dash (-) separators. You can set the Mask to be "&gt;aa\:aa\:aa\:aa\:aa\:aa", which will make all characters typed in go to uppercase ('&gt;'), accept, optionally, two alphanumeric characters ('aa') followed by a literal colon ('\:'), and so on. (The reason for the literal colon is so that it isn't translated to a different Time separator character.)&#13;
&#13;
Unfortunately, I don't think there is a way to specify that the separator can be either a dash *or* a colon, but, in my test, pasting in input with either separator (or none) works ok (i.e. "A0-b1-C2-d3-E4-f5", "A0:b1:C2:d3:E4:f5", or "A0b1C2d3E4f5"). Another limitation is that the input is optional, but that can be compensated for in your own validation code. That code should start by assigning the ValidatingType of your MTB to typeof(Mac). (Of course, you need to create a Mac class for doing MAC address manipulation, since .NET doesn't include one for you.) [Edit: .NET does have a built-in MAC address class: System.Net.NetworkInformation.PhysicalAddress] Look up the MSDN for ValidatingType to know what all the class needs to support for this functionality.&#13;
&#13;
For the IP address, things are a little easier but a little worse. The MTB doesn't appear to support variable-length input (e.g. "1" as well as "192"), so we can't use the mask to our advantage. (If you don't believe me, try a Mask of "990\.990\.990\.990" and see.) So our UI isn't as nice, but oh well. For validation, set the ValidatingType to typeof(System.Net.IPAddress) and cast your e.ReturnValue in your TypeValidationCompleted event handler to that same type.&#13;
&#13;
That's it. A bit of a cursory explanation, but you should be able to piece together the rest. Leave questions if you have 'em.&lt;/p&gt;</description>
      <pubDate>Tue, 03 Nov 2009 15:33:13 UTC</pubDate>
      <guid>https://snipplr.com/view/22421/visual-studio-net-controls-for-taking-ip-address-and-mac-address-info-as-inputs</guid>
    </item>
    <item>
      <title>(C#) User input validation in Visual Studio .NET using MaskedTextBoxes and an ErrorProvider - pckujawa</title>
      <link>https://snipplr.com/view/22419/user-input-validation-in-visual-studio-net-using-maskedtextboxes-and-an-errorprovider</link>
      <description>&lt;p&gt;I just discovered that the MaskedTextBox control allows you to set the type of data which should be entered in the control and helps you do the validation of that data when necessary. The trick is to set the ValidatingType of the MaskedTextBox control to the type of data you want to get from the user. If you do this, as well as subscribe to the TypeValidationCompleted event, on the form Load event, you can handle user validation inside your TypeValidationCompleted event handler.&#13;
&#13;
If you want to read about the MaskedTextBox, it's all on MSDN. What you should be aware of, though, is that the Mask is *not* required. When the mask is blank, you can accept input just like you can with a TextBox.&#13;
&#13;
The ErrorProvider is a WinForms control that allows you to show a red exclamation mark with an error message tooltip next to a control. It's really useful when combined with the above data validation method.&#13;
&#13;
The example shows us setting the type of data which should be entered into the text box and then subscribing to the corresponding event. In that event handler, we check if the input is valid (don't know what all that does, but it works - play with it) and, if so, cast the value to the correct data type in order to use for some purpose. We also clear any errors in the ErrorProvider (not sure of the best way to use this control, but this works). If the input is not valid, we set the error shown by the ErrorProvider (the e.Message is generally the same as the Message parameter of any exception that has been thrown). (You can set the error to the control by name, or generically by using the sender argument.)&lt;/p&gt;</description>
      <pubDate>Tue, 03 Nov 2009 15:05:27 UTC</pubDate>
      <guid>https://snipplr.com/view/22419/user-input-validation-in-visual-studio-net-using-maskedtextboxes-and-an-errorprovider</guid>
    </item>
    <item>
      <title>(Other) Scroll up or down one line at a time in MS Word (using keyboard) - pckujawa</title>
      <link>https://snipplr.com/view/18827/scroll-up-or-down-one-line-at-a-time-in-ms-word-using-keyboard</link>
      <description>&lt;p&gt;I've wanted to be able to do this for a long time, but could never figure out how. You need to create two macros and (http://answers.microsoft.com/en-us/office/forum/officeversion_other-word/how-can-i-assign-or-change-keyboard-shortcuts-to/5ea9ac54-494d-4a09-9104-91ea41f7d305)[assign them to keyboard shortcuts] (I use Ctrl+Up/Down, since they are standard in IDEs).&lt;/p&gt;</description>
      <pubDate>Tue, 25 Aug 2009 11:34:32 UTC</pubDate>
      <guid>https://snipplr.com/view/18827/scroll-up-or-down-one-line-at-a-time-in-ms-word-using-keyboard</guid>
    </item>
    <item>
      <title>(C#) Testing asynchronous methods in .NET (or, how to make an async method synchronous) - pckujawa</title>
      <link>https://snipplr.com/view/18177/testing-asynchronous-methods-in-net-or-how-to-make-an-async-method-synchronous</link>
      <description>&lt;p&gt;Since an asynchronous method is usually one you call and then it invokes a callback when it is finished, it is not obvious how to test such a method in a definite manner. In the method described at the above URL, the author uses .NET's System.Threading.AutoResetEvent, along with a member variable, to notify the primary thread that the test method has finished. The source below (from Radiant::Mirage::Empire) tests a method called ReadVersion from an API which fires events at the completion of each command or a special event if there is an error. The static constructor initializes the API, subscribes to the Error event, and adds Trace output to the Console. The two event listeners simply log data (to Trace or to a member variable) and then set the AutoResetEvent so that the calling method can proceed. AsyncTest is a method that allows me to call a method and then perform the same, standard procedures afterwards (creating the AutoResetEvent, waiting for the thread to return, and outputting to Trace). The actual test method, ReadVersionTest, calls AsyncTest with a lambda (which is an anonymous method that gets called inside AsyncTest) that subscribes to the relevant event and issues the specified command. The ReadVersionTestComplete method shows what the code would look like without using the AsyncTest method and lambda.&lt;/p&gt;</description>
      <pubDate>Tue, 11 Aug 2009 10:55:32 UTC</pubDate>
      <guid>https://snipplr.com/view/18177/testing-asynchronous-methods-in-net-or-how-to-make-an-async-method-synchronous</guid>
    </item>
    <item>
      <title>(C#) Compare iterated types (IEnumerables and their kin) by values (to check for equality) - pckujawa</title>
      <link>https://snipplr.com/view/17889/compare-iterated-types-ienumerables-and-their-kin-by-values-to-check-for-equality</link>
      <description>&lt;p&gt;When I'm running unit tests, I find it very annoying to have to check equality within loops when I've got two collections of data. I know of no built-in way (let me know if there is one) [Edit: [CollectionAssert](http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.collectionassert.aspx) does it. Sometimes you need to turn your IEnumerables into arrays, though, using .ToArray()] to compare two collections' values (such as an array of bytes compared to a list of bytes), so I made this extension method to do it.&lt;/p&gt;</description>
      <pubDate>Tue, 04 Aug 2009 13:11:50 UTC</pubDate>
      <guid>https://snipplr.com/view/17889/compare-iterated-types-ienumerables-and-their-kin-by-values-to-check-for-equality</guid>
    </item>
    <item>
      <title>(C#) Get HTML from a URI - pckujawa</title>
      <link>https://snipplr.com/view/17389/get-html-from-a-uri</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 23 Jul 2009 11:56:11 UTC</pubDate>
      <guid>https://snipplr.com/view/17389/get-html-from-a-uri</guid>
    </item>
    <item>
      <title>(C#) Convert a binary coded decimal (BCD) string into bytes - pckujawa</title>
      <link>https://snipplr.com/view/17008/convert-a-binary-coded-decimal-bcd-string-into-bytes</link>
      <description>&lt;p&gt;BCD is where the hex value of a byte represents two integer values between zero and nine; e.g., 0x98 -&gt; "98" (whereas its integer value is actually 152). The method throws an exception if non-BCD data is input.&#13;
&#13;
You can also check out the partner method, [Convert bytes into a binary coded decimal (BCD) string](http://snipplr.com/view/16802/convert-bytes-into-a-binary-coded-decimal-bcd-string/).&#13;
&#13;
Update:    &#13;
Unfortunately, there doesn't seem to be a built-in method for doing this (there is for the converse; see System.BitConverter.ToString). The System.BitConverter.GetBytes(char) overload returns the byte value of the character, rather than a BCD byte array (`BitConverter.GetBytes('A')` returns a byte array holding `[65, 0]`, not [0x0A] as we would want).&lt;/p&gt;</description>
      <pubDate>Tue, 14 Jul 2009 14:21:15 UTC</pubDate>
      <guid>https://snipplr.com/view/17008/convert-a-binary-coded-decimal-bcd-string-into-bytes</guid>
    </item>
    <item>
      <title>(C#) Convert bytes into a binary coded decimal (BCD) string - pckujawa</title>
      <link>https://snipplr.com/view/16802/convert-bytes-into-a-binary-coded-decimal-bcd-string</link>
      <description>&lt;p&gt;BCD is where the hex value of a byte represents two integer values between zero and nine; e.g., 0x98 -&gt; "98" (whereas its integer value is actually 152). The method throws an exception if non-BCD data is input.&#13;
&#13;
There is actually a built-in method to do BCD: System.BitConverter.ToString. Note, though, that BitConverter only uses the endianness of the host machine, so you might need to convert to Big or Little Endian depending on the data source or  destination.&#13;
&#13;
Example: `BitConverter.ToString(new byte[] {0xAE, 0xD0})` gives us the string `AE-D0`.&lt;/p&gt;</description>
      <pubDate>Thu, 09 Jul 2009 11:19:57 UTC</pubDate>
      <guid>https://snipplr.com/view/16802/convert-bytes-into-a-binary-coded-decimal-bcd-string</guid>
    </item>
    <item>
      <title>(C#) Generate help file documentation for .NET projects from XML code comments - pckujawa</title>
      <link>https://snipplr.com/view/15432/generate-help-file-documentation-for-net-projects-from-xml-code-comments</link>
      <description>&lt;p&gt;Essentially, you need to tell Visual Studio to generate an XML file with documentation, then use a separate tool to create a help file (usually .chm) out of that XML file. The tool to use is MS's Sandcastle. You'll also want a GUI for Sandcastle, which would be Sandcastle Help File Builder.&lt;/p&gt;</description>
      <pubDate>Mon, 01 Jun 2009 14:16:37 UTC</pubDate>
      <guid>https://snipplr.com/view/15432/generate-help-file-documentation-for-net-projects-from-xml-code-comments</guid>
    </item>
    <item>
      <title>(C#) Adapt System.BitConverter to handle big endian (network) byte ordering in order to create number types from bytes and vice-versa - pckujawa</title>
      <link>https://snipplr.com/view/15179/adapt-systembitconverter-to-handle-big-endian-network-byte-ordering-in-order-to-create-number-types-from-bytes-and-viceversa</link>
      <description>&lt;p&gt;The System.BitConverter class allows you to convert between bytes (in an array) and numerical types (int, uint, etc). However, it doesn't seem to let you set the endianness (which byte is most significant, e.g. in an int/Int32, there are four bytes, so which way do you read them?). It seems to operate such that the methods always return values appropriate to little endian (host order) systems (most significant byte is on the right). Since, in embedded systems, it is often necessary to interact with big-endian systems, I created this class to provide the functionality for either endianness. You simply set the endianness in the class, then all methods will return endian-aware values.&#13;
&#13;
Please let me know if there is a better solution out there, as I searched a lot before deciding to do it this way. (Note: Instead of using LINQ [e.g. myArray.Reverse().ToArray()], you can use Array.Reverse(myArray).)&#13;
&#13;
Found a bug in the previous code in that the arrays were being reversed, but the starting index was not, resulting in non-obvious behavior. I fixed that for all but the ToString methods.&lt;/p&gt;</description>
      <pubDate>Tue, 19 May 2009 17:16:47 UTC</pubDate>
      <guid>https://snipplr.com/view/15179/adapt-systembitconverter-to-handle-big-endian-network-byte-ordering-in-order-to-create-number-types-from-bytes-and-viceversa</guid>
    </item>
    <item>
      <title>(C#) Raise and handle events generically - pckujawa</title>
      <link>https://snipplr.com/view/15033/raise-and-handle-events-generically</link>
      <description>&lt;p&gt;For a discussion of .NET events best-practices, see [Roy Osherove's blog post](http://weblogs.asp.net/rosherove/articles/DefensiveEventPublishing.aspx) and [this post](http://blogs.msdn.com/ericlippert/archive/2009/04/29/events-and-races.aspx). Be sure to read the comments sections for some good arguments for and against the presented methods. Also, there is a good [MSDN Magazine article on Event Accessors](http://msdn.microsoft.com/en-us/magazine/cc163533.aspx), which may be useful.&#13;
&#13;
Used in "Empire." The example shows an EventArgs with a DateTime object, but it could be a string or enumeration or whatever.&lt;/p&gt;</description>
      <pubDate>Thu, 14 May 2009 16:30:42 UTC</pubDate>
      <guid>https://snipplr.com/view/15033/raise-and-handle-events-generically</guid>
    </item>
    <item>
      <title>(DOS Batch) Wait for user input (pause) for batch file (command line, cmd, dos prompt, ...) - pckujawa</title>
      <link>https://snipplr.com/view/14935/wait-for-user-input-pause-for-batch-file-command-line-cmd-dos-prompt-</link>
      <description>&lt;p&gt;I always forget, so here it is forever - just put this simple line at the end of the batch file and the command prompt will remain until a key is pressed.&lt;/p&gt;</description>
      <pubDate>Tue, 12 May 2009 18:59:48 UTC</pubDate>
      <guid>https://snipplr.com/view/14935/wait-for-user-input-pause-for-batch-file-command-line-cmd-dos-prompt-</guid>
    </item>
    <item>
      <title>(Visual Basic) Look up all occurences and merge results (consolidate) - pckujawa</title>
      <link>https://snipplr.com/view/12713/look-up-all-occurences-and-merge-results-consolidate</link>
      <description>&lt;p&gt;Say you've got data combined in such a way that there is a repeated row header, but all the data is in different rows. If you were to consolidate all the rows down to one, only taking valid values (discarding blanks), you'd have one header row with all the data. This function does that for you.&#13;
&#13;
Ex:  &#13;
`StudentID,TestScore1, TestScore2,TestScore3  &#13;
1,100,,  &#13;
1,,98,  &#13;
1,,,97`&#13;
&#13;
Becomes:  &#13;
`StudentID,TestScore1, TestScore2,TestScore3  &#13;
1,100,98,97`&lt;/p&gt;</description>
      <pubDate>Mon, 02 Mar 2009 02:18:37 UTC</pubDate>
      <guid>https://snipplr.com/view/12713/look-up-all-occurences-and-merge-results-consolidate</guid>
    </item>
    <item>
      <title>(C#) Pass a string from C# to a C++ DLL in .NET (and get a pointer to the string's chars) - pckujawa</title>
      <link>https://snipplr.com/view/12509/pass-a-string-from-c-to-a-c-dll-in-net-and-get-a-pointer-to-the-strings-chars</link>
      <description>&lt;p&gt;Specifically, this code enables you to pass a string from C# into C++ managed code and then get a C++ pointer to the string's chars.&#13;
&#13;
[Marshal.StringToHGlobalAnsi Method](http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.stringtohglobalansi.aspx) from MSDN.&#13;
&#13;
Good [information about native vs. managed types](http://blog.rednael.com/2008/08/29/MarshallingUsingNativeDLLsInNET.aspx).&#13;
&#13;
Related [forum post](http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/5fe46030-76f7-4988-9ce3-fc21a30ee3a2/).&lt;/p&gt;</description>
      <pubDate>Mon, 23 Feb 2009 11:38:49 UTC</pubDate>
      <guid>https://snipplr.com/view/12509/pass-a-string-from-c-to-a-c-dll-in-net-and-get-a-pointer-to-the-strings-chars</guid>
    </item>
    <item>
      <title>(C#) .NET Getting and Setting the Application Version Number and other application attributes - pckujawa</title>
      <link>https://snipplr.com/view/11761/net-getting-and-setting-the-application-version-number-and-other-application-attributes</link>
      <description>&lt;p&gt;If you are just looking for the version information in the assembly, you can use `Application.ProductVersion` (at least for GUI applications). I don't think you'll get the reflection performance hit this way.&#13;
&#13;
You can also add an "About" box to your GUI and see what code is generated for all of that information (product name, copyright, version, etc).&lt;/p&gt;</description>
      <pubDate>Mon, 02 Feb 2009 13:52:29 UTC</pubDate>
      <guid>https://snipplr.com/view/11761/net-getting-and-setting-the-application-version-number-and-other-application-attributes</guid>
    </item>
    <item>
      <title>(C#) Create IEnumerable&amp;lt;string&amp;gt; to manually enumerate over string values - pckujawa</title>
      <link>https://snipplr.com/view/11153/create-ienumerableltstringgt-to-manually-enumerate-over-string-values</link>
      <description>&lt;p&gt;Ever need to enumerate over a collection of strings? Simple, just `foreach(string str in stringContainer)` and you've got them, right? Well, what if you want to enumerate over them manually? Basically, you can't (as far as I've found). You can do `stringContainer.GetEnumerator()`, but that returns a System.Collections.IEnumerator, which holds objects, not strings (thus requiring an explicit cast to get the string value). That is, you cannot do  &#13;
    `IEnumerator en = stringContainer.GetEnumerator();  &#13;
    en.MoveNext();  &#13;
    string myString = en.Current;`  &#13;
You have to do  &#13;
    `string myString = Convert.ToString(en.Current);`&#13;
&#13;
I don't know why C# doesn't have this built in, but it doesn't (and trying to cast to IEnumerator&amp;lt;string&amp;gt; throws an exception). So, there are a lot of homegrown solutions out there, but this one is the easiest for my application. I needed to read in values from a file and assign them to string variables. Since there are a lot of variables, and their order is sometimes changed between versions, it is a pain to assign each variable by its array index (the array being created by reading in each line and splitting it with a comma). It is much easier to change the ordering of variables by simply moving the line up or down in the source code. Thus the need for an enumerator and my dilemma.&#13;
&#13;
The URL refers to similar code from an O'Reilly book.&#13;
&#13;
The 'yield return' statement essentially returns one value from a collection each time a value is needed (such as in a foreach or enum.MoveNext), but keeps track of ordering for you. Pretty slick. Google it for more info.&lt;/p&gt;</description>
      <pubDate>Tue, 13 Jan 2009 19:04:35 UTC</pubDate>
      <guid>https://snipplr.com/view/11153/create-ienumerableltstringgt-to-manually-enumerate-over-string-values</guid>
    </item>
    <item>
      <title>(C#) Set the directory (connection string) for an SQL Server Database Connection - pckujawa</title>
      <link>https://snipplr.com/view/10502/set-the-directory-connection-string-for-an-sql-server-database-connection</link>
      <description>&lt;p&gt;This snippet is actually tested for SQL Server Compact Edition (CE) 3.5, but it will probably work for other SQL Server editions. Once you have an SQL CE db up and running, you can set the connection string to point to any directory and database by simply using the |DataDirectory| string in the dbConnectionString Property (created by default when you create the database connection) and then relocating the location to which |DataDirectory| points by calling AppDomain.CurrentDomain.SetData("DataDirectory", @"C:\Path\To\DB"). Since the dbConnectionString property appends \dbName.sdf, we leave that part off of the SetData argument.&#13;
&#13;
The code below sets the data directory to the common application data folder (usually C:\Documents and Settings\All Users\Application Data on winXP). It seems to work fine when invoked in the Form_Load method.&lt;/p&gt;</description>
      <pubDate>Mon, 15 Dec 2008 11:59:07 UTC</pubDate>
      <guid>https://snipplr.com/view/10502/set-the-directory-connection-string-for-an-sql-server-database-connection</guid>
    </item>
    <item>
      <title>(C#) Getting Application Data and other Special Folders Paths - pckujawa</title>
      <link>https://snipplr.com/view/10434/getting-application-data-and-other-special-folders-paths</link>
      <description>&lt;p&gt;Thanks to Jon Koon for this one. Other special folders can be obtained through the System.Environment.SpecialFolder enumeration (such as the desktop, my computer, my docs, etc).&lt;/p&gt;</description>
      <pubDate>Fri, 12 Dec 2008 13:42:16 UTC</pubDate>
      <guid>https://snipplr.com/view/10434/getting-application-data-and-other-special-folders-paths</guid>
    </item>
    <item>
      <title>(C#) Example of subscribing to and firing events - pckujawa</title>
      <link>https://snipplr.com/view/10291/example-of-subscribing-to-and-firing-events</link>
      <description>&lt;p&gt;See [Raise and Handle Events Generically](http://snipplr.com/view/15033/raise-and-handle-events-generically/) for a better way to use events (generically) and links to best practices in .NET events.&#13;
&#13;
This example should be used as a Console program and will simply write a line of text to the console. It shows how to create an event handler in a class, have that event handler fire an event with custom information, and how to subscribe to that event and use its data. I hope it is straightforward enough.&lt;/p&gt;</description>
      <pubDate>Fri, 05 Dec 2008 14:12:19 UTC</pubDate>
      <guid>https://snipplr.com/view/10291/example-of-subscribing-to-and-firing-events</guid>
    </item>
    <item>
      <title>(C#) Scroll to the bottom of a text box control programmatically - pckujawa</title>
      <link>https://snipplr.com/view/9922/scroll-to-the-bottom-of-a-text-box-control-programmatically</link>
      <description>&lt;p&gt;This technique is useful for when you are displaying text back to the user in a GUI and want the most recent text to be displayed at the bottom of the text control, but you want that information to be visible.&#13;
&#13;
Another nice function that works well if you arenâ€™t moving up and down in the text box is the textbox.AppendText function.  It will add the text to the bottom and keep the textbox from going to the top. (Thanks to Charlie Mann for that one.)&lt;/p&gt;</description>
      <pubDate>Wed, 19 Nov 2008 12:17:29 UTC</pubDate>
      <guid>https://snipplr.com/view/9922/scroll-to-the-bottom-of-a-text-box-control-programmatically</guid>
    </item>
  </channel>
</rss>
