<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andrew&#039;s Blog</title>
	<atom:link href="http://andrew.lowe.id.au/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrew.lowe.id.au/blog</link>
	<description>about Technology</description>
	<lastBuildDate>Thu, 22 Dec 2011 00:18:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Disable Netbeans Document Close Buttons</title>
		<link>http://andrew.lowe.id.au/blog/2011/02/disable-netbeans-document-close-buttons/</link>
		<comments>http://andrew.lowe.id.au/blog/2011/02/disable-netbeans-document-close-buttons/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 02:58:09 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[netbeans macosx]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=119</guid>
		<description><![CDATA[To disable netbeans document close tabs on MacOSX (because I keep hitting them when selecting a tab):
edit /Applications/NetBeans/NetBeans\ 6.9.app/Contents/Resources/NetBeans/etc/netbeans.conf (where 6.9 is the version number)
and add (append) to netbeans_default_options the following:
-J-Dnb.tabs.suppressCloseButton=true
Restart netbeans, and your document close buttons on the tabs are gone.
]]></description>
			<content:encoded><![CDATA[<p>To disable netbeans document close tabs on MacOSX (because I keep hitting them when selecting a tab):</p>
<p>edit /Applications/NetBeans/NetBeans\ 6.9.app/Contents/Resources/NetBeans/etc/netbeans.conf (where 6.9 is the version number)</p>
<p>and add (append) to netbeans_default_options the following:</p>
<p>-J-Dnb.tabs.suppressCloseButton=true</p>
<p>Restart netbeans, and your document close buttons on the tabs are gone.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2011/02/disable-netbeans-document-close-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EqualLogic Recover Replicant Failover with XenCenter</title>
		<link>http://andrew.lowe.id.au/blog/2010/10/equallogic-recover-replicant-failover-with-xencenter/</link>
		<comments>http://andrew.lowe.id.au/blog/2010/10/equallogic-recover-replicant-failover-with-xencenter/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 04:36:43 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[EqualLogic]]></category>
		<category><![CDATA[xen]]></category>
		<category><![CDATA[xencenter]]></category>
		<category><![CDATA[xenserver]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=108</guid>
		<description><![CDATA[This post will document the procedure to switch back to production hardware after failover to a replicant on EqualLogic Groups, with XenCenter...]]></description>
			<content:encoded><![CDATA[<p>This post will document the procedure to switch back to production hardware after failover to a replicant on EqualLogic Groups, with XenCenter.</p>
<p>This post is a follow-up to the previous one about <a title="Fail-over to replicant" href="http://andrew.lowe.id.au/blog/2010/10/equallogic-failover-to-replicant-for-xenserver/" target="_blank">failover to a replicant</a>, so assumes you have failed over, and want to fall back to production.</p>
<p><strong>XenCenter</strong></p>
<ul>
<li>Stop the Virtual Machine</li>
<li>Detach the Storage Repository (only detatch, do not destroy or forget). Answer â€šÃ„ÃºYesâ€šÃ„Ã¹ to the confirmation dialog, and wait until the detach process is complete (check the Storage Repositories logs).</li>
</ul>
<p><strong>D.R. EqualLogic Group Manager</strong></p>
<ul>
<li>Under Volumes, select the volume you wish to fall back to production.</li>
<li>Under &#8220;Replication Failback&#8221; options, select &#8220;Failback to primary&#8221;</li>
<li>Click the &#8220;Yes&#8221; button on the confirmation dialog.</li>
<li>Provide an administrator account name and password, for the Production Group, and click OK. Â¬â€ Do not click &#8220;Perform manual replication&#8221;. Â¬â€ This step will replicate the changes over to the production volume, and set the volume online when complete.</li>
<li>At the bottom of the Group Manager screen, you will see an operation icon flashing, you can monitor this process by clicking the icon.</li>
</ul>
<p><strong>XenCenter</strong></p>
<ul>
<li>Re-attach the Storage Repository, using the production server IP as the &#8220;Target Host&#8221;, pressing &#8220;Discover IQNs&#8221; and select the IQN from the list (it will have the volume name at the end of the IQN). Press the &#8220;Discover LUNs&#8221; button, and Finish, as there will only be one LUN.</li>
<li>Click &#8220;Yes&#8221; to the confirmation dialog.</li>
<li>Start the Virtual Machine.</li>
</ul>
<pÃŠÃ¯ÂµTh>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2010/10/equallogic-recover-replicant-failover-with-xencenter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EqualLogic Failover to Replicant for XenServer</title>
		<link>http://andrew.lowe.id.au/blog/2010/10/equallogic-failover-to-replicant-for-xenserver/</link>
		<comments>http://andrew.lowe.id.au/blog/2010/10/equallogic-failover-to-replicant-for-xenserver/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 03:54:04 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[EqualLogic]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[xen]]></category>
		<category><![CDATA[xencenter]]></category>
		<category><![CDATA[xenserver]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=106</guid>
		<description><![CDATA[This post will document the procedure to fail-over to a replicant volume on a second EqualLogic Group, when using XenServer...]]></description>
			<content:encoded><![CDATA[<p>This post will document the procedure to fail-over to a replicant volume on a second EqualLogic Group, when using XenServer.</p>
<p>The recovery process is in a <a title="Recovery" href="http://andrew.lowe.id.au/blog/2010/10/equallogic-recover-replicant-failover-with-xencenter/" target="_blank">separate entry</a></p>
<p><strong>XenCenter</strong></p>
<ul>
<li>Stop the Virtual Machine</li>
<li>Detach the Storage Repository (only detatch, do not destroy or forget). Answer â€šÃ„ÃºYesâ€šÃ„Ã¹ to the confirmation dialog, and wait until the detach process is complete (check the Storage Repositories logs).</li>
</ul>
<p>If this is a planed failover, and all hardware is online and working, you will want to perform a final replication now, to copy changes since the last replication to the D.R. group. Â¬â€ If this is unplanned, and the production hardware is offline, then you will lose any data since the last replication.</p>
<p><strong>D.R. EqualLogic Group Manager (replication target)</strong></p>
<ul>
<li>Promote the Replica Volume: Click on the Replication tab, and select the production group under &#8220;Replication Partners&#8221;, then &#8220;Inbound Replicas&#8221;, and select the replica volume you wish to restore. Click on &#8220;Promote to volume&#8221;, this will promote the last replica to a volume. Â¬â€ To use another replica, you need to clone the replica to a new volume, which is outside this procedure.</li>
<li>Click &#8220;Yes&#8221; to the confirmation dialog, which will prompt you that inbound replication will pause during the promotion.</li>
<li>Make sure both the boxes (Set volume online, and Retain target name of the original volume) are ticked, and click Next.</li>
<li>Set the iSCSI access (by IP address, use asterisks for wildcards), and access type (Set read-write, and Allow simultaneous connections is ticked), and click Next.</li>
<li>Click Finish.</li>
</ul>
<p><strong>XenCenter</strong></p>
<ul>
<li>Re-attach the Storage Repository using the D.R. Group address as the target host, &#8220;Discover IQNs&#8221; selecting the correct IQN from the list, then &#8220;Discover LUNs&#8221;, there should only be one.</li>
<li>Click Finish.</li>
<li>Click &#8220;Yes&#8221; to the confirmation dialog.</li>
<li>Start the Virtual Machine.</li>
</ul>
<p><strong>Production EqualLogic Group Manager</strong> (when possible, i.e., when it is back online)</p>
<ul>
<li>Select the volume you have promoted to D.R.</li>
<li>Select under Replication Failback, &#8220;Demote to replica set&#8221;.</li>
<li>There will be a confirmation dialog, making sure you have completed the promotion steps above, select &#8220;Yes&#8221; to this dialog.</li>
<li>If you recover from a disaster (i.e., failure of production, and it was an unexpected shut), it will suggest that there are changes to the volume that have not been replicated, we will select &#8220;No&#8221; here, and lose the changes, as we have already started using the replica, and are recovering from an unexpected shut, and know we were going to lose data.</li>
<li>This process will move the volume to the inbound replicas on the production group.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2010/10/equallogic-failover-to-replicant-for-xenserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restore EqualLogic Snapshot for XenCenter</title>
		<link>http://andrew.lowe.id.au/blog/2010/10/restore-equallogic-snapshot-for-xencenter/</link>
		<comments>http://andrew.lowe.id.au/blog/2010/10/restore-equallogic-snapshot-for-xencenter/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 03:22:32 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[EqualLogic]]></category>
		<category><![CDATA[snapshot]]></category>
		<category><![CDATA[xen]]></category>
		<category><![CDATA[xencenter]]></category>
		<category><![CDATA[xenserver]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=102</guid>
		<description><![CDATA[The following documents the procedure to restore a snapshot of a Xen Virtual Machine stored on an EqualLogic Storage Group....]]></description>
			<content:encoded><![CDATA[<p>The following documents the procedure to restore a snapshot of a Xen Virtual Machine stored on an EqualLogic Storage Group.</p>
<p><strong>XenCenter</strong></p>
<ul>
<li>Stop the Virtual Machine</li>
<li>Detach the Storage Repository (only detatch, do not destroy or forget).  Answer &#8220;Yes&#8221; to the confirmation dialog, and wait until the detach process is complete (check the Storage Repositories logs).</li>
</ul>
<p><strong>EqualLogic Group Manager</strong></p>
<ul>
<li>Set the desired volume offline, answering yes to the confirmation.</li>
<li>Select &#8220;Restore volume&#8221;, and select the volume you wish to restore, and click &#8220;OK&#8221;.    On the confirmation dialog, make sure &#8220;Set volume online after restore is complete&#8221;is ticked, and click the &#8220;Yes&#8221; button. This take a snapshot of the current volume state, and will make the selected snapshot the current volume.</li>
</ul>
<p><strong>XenCenter</strong></p>
<ul>
<li>Re-attach the Storage Repository. You will need to provide the IP Address of the production storage array in the Target Host field, press the &#8220;Discover IQNs&#8221; button, and select the correct Target IQN from the list (it will end in the volume name), and press &#8220;Discover LUNs&#8221; button, there should be only 1 LUN (0) in the list, and press the &#8220;Finish&#8221; button.</li>
<li>Press the &#8220;Yes&#8221; button to the confirmation dialog that gets you to check the Storage Repository is not being used by any XenServer.</li>
<li>XenCenter will plug the store into each production XenServer, and close the window.</li>
<li>Start the Virtual Machine.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2010/10/restore-equallogic-snapshot-for-xencenter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux IO: Part 2 &#8211; Apache</title>
		<link>http://andrew.lowe.id.au/blog/2010/07/linux-io-part-2-apache/</link>
		<comments>http://andrew.lowe.id.au/blog/2010/07/linux-io-part-2-apache/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 04:48:49 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[io]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=96</guid>
		<description><![CDATA[A tool I discovered: apachetop can read apache log files, and show performance data in a human readable format. apachetop will use the default apache log files, and apachetop -f /path/to/logfile will show stats for a selected log file.
Many hosts are configured using virtual hosts, and logging is done to separate log files for each [...]]]></description>
			<content:encoded><![CDATA[<p>A tool I discovered: apachetop can read apache log files, and show performance data in a human readable format. <code>apachetop</code> will use the default apache log files, and <code>apachetop -f /path/to/logfile</code> will show stats for a selected log file.<span id="more-96"></span><br />
Many hosts are configured using virtual hosts, and logging is done to separate log files for each virtual hosts.  If this is the case, for performance debugging, it is a good idea to add a second log entry into the global log file.  You can run as many CustomLog entries as you like.<br />
<code><br />
	CustomLog /var/log/httpd/customer_virtual_host-access_log combined<br />
	CustomLog logs/access_log combined<br />
</code><br />
I have not looked to far into apachetop, but you can see the requests, requests per second, KB, KB/s and url of the file by default.  There are more options, such as sort by, referers, and more and you can see these by pressing the &#8220;h&#8221; or &#8220;?&#8221; keys.<br />
For some more info:<br />
<a href="http://www.howtogeek.com/howto/ubuntu/monitor-your-website-in-real-time-with-apachetop/">http://www.howtogeek.com/howto/ubuntu/monitor-your-website-in-real-time-with-apachetop/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2010/07/linux-io-part-2-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux IO: Part 1 &#8211; Disk and Network</title>
		<link>http://andrew.lowe.id.au/blog/2010/07/linux-io-part-1/</link>
		<comments>http://andrew.lowe.id.au/blog/2010/07/linux-io-part-1/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 00:47:25 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[io]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=82</guid>
		<description><![CDATA[Linux IO is a pretty big topic, and this is just a quick entry with some links and notes about tools I have found, I hope to do a more in depth look later.  This post covers Network and Disk IO from a basic point of view.]]></description>
			<content:encoded><![CDATA[<p>Linux IO is a pretty big topic, and this is just a quick entry with some links and notes about tools I have found, I hope to do a more in depth look later.</p>
<p>First up <strong>Network IO</strong>:<br />
The command <code>ifstat</code> gives you a pretty decent look at current bandwidth usage.  <code>ifstat -l</code> will also show loopback devices</p>
<p>Next Up <strong>Disk IO</strong>, this is a pretty big one, as this is probably a big cause of system load in my environments.<br />
The command <code>iostat</code> gives a basic run down of the disk usage.<br />
Using the eXtended option <code>iostat -x</code> gives you a more detailed look, and is much more useful in finding issues.<br />
Running with an interval at the end will re-run the stats using live data, which again is more useful, and will refresh the display: <code>iostat -x 1</code> will refresh the data every 1 second.</p>
<ol>
<li>r/s and w/s are the requests by a process to read and write to the device</li>
<li>rsec/s and wsec/s sectors per second.</li>
<li>avgrq-sz is the average sectors per request (both read an write). Divide by 2 to get bytes.</li>
<li>avgqu-sz is the average queue length</li>
<li>await is the average wait time for a request, includes the queue time and the service time</li>
<li>svctm is the average time spent servicing requests, the actual read/write time</li>
<li>%util is the utilisation percentage, not quite accurate on shared storage/multiple disk raid</li>
</ol>
<p>To calculate the queue time, take the svctm from await.<br />
If the queue time is greater then the service time, then the device is probably overloaded.  Ideally the await should be pretty much equal to the svctm figure, as then there are not many requests being queued.</p>
<p>Some good references:<br />
Quick Reference about iostat<br />
<a href="http://www.pythian.com/news/247/basic-io-monitoring-on-linux/<br />
">http://www.pythian.com/news/247/basic-io-monitoring-on-linux/<br />
</a>and a detailed blog entry on iostat, and linux disk IO in general&#8230;<br />
<a href="http://blog.serverfault.com/post/777852755/interpreting-iostat-output<br />
">http://blog.serverfault.com/post/777852755/interpreting-iostat-output<br />
</a><br />
As a final note, for VMWare ESX, have a look at esxtop, and use the d and v and u keys to display various disk related stats, see man esxtop for more, and I hope to cover more later&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2010/07/linux-io-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VSphere 4 Essentials Plus &#8211; Adding Hosts</title>
		<link>http://andrew.lowe.id.au/blog/2010/02/vsphere-4-essentials-plus-adding-hosts/</link>
		<comments>http://andrew.lowe.id.au/blog/2010/02/vsphere-4-essentials-plus-adding-hosts/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 00:14:07 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[vcenter]]></category>
		<category><![CDATA[virtualcenter]]></category>
		<category><![CDATA[vmotion]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[vsphere]]></category>
		<category><![CDATA[vsphere essentials]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=80</guid>
		<description><![CDATA[Disable VMotion in the Storage Network on the ESX Host to remove the VMotion License error message.]]></description>
			<content:encoded><![CDATA[<p>VSphere 4 Essentials Plus is a cheaper option giving you 3 ESX hosts and a Management Server (VirutalCenter)<br />
When adding hosts that have ISCSI storage you may get an error indicating that you need a VMotion License, and to upgrade your host.<br />
Essentials Plus licences do not include VMotion.<br />
You need to edit the ESX Host Storage Network adaptor, and untick the &#8220;Enable VMotion&#8221; box.  This option is causing the error message.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2010/02/vsphere-4-essentials-plus-adding-hosts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SOAP with PHP 5.2 Object References and .Net</title>
		<link>http://andrew.lowe.id.au/blog/2009/11/using-soap-with-php-5-2-object-references-and-net/</link>
		<comments>http://andrew.lowe.id.au/blog/2009/11/using-soap-with-php-5-2-object-references-and-net/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 04:27:40 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[soap]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=74</guid>
		<description><![CDATA[PHP 5 introduces object references, where objects are assigned by reference (when you do $b=$a) they both point to the same object.  This causes problems when using references with the SOAP server functions.]]></description>
			<content:encoded><![CDATA[<p>PHP 5 introduces object references, where objects are assigned by reference (when you do $b=$a) they both point to the same object.  This causes problems when using references with the SOAP server functions.</p>
<p>With earlier version of the SOAP library (5.1, etc) the soap server translated these into the full object (very pseudo code):</p>
<p>As of PHP 5.2, the SOAP code, translates this to use references:</p>
<p>This causes problems with .Net clients and servers, which don&#8217;t respect the href options.<br />
The solution, use clone: $b=clone $a.<br />
For more detail where Thijs Feryn has a great article on the topic &#8230;<br />
<a href="http://blog.feryn.eu/2009/01/warning-object-references-affect-xml-serialization/">http://blog.feryn.eu/2009/01/warning-object-references-affect-xml-serialization/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2009/11/using-soap-with-php-5-2-object-references-and-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Soap Client Max Message Size</title>
		<link>http://andrew.lowe.id.au/blog/2009/10/soap-client-max-message-size/</link>
		<comments>http://andrew.lowe.id.au/blog/2009/10/soap-client-max-message-size/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 06:02:42 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[soap]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=71</guid>
		<description><![CDATA[Just found a solution to the max message size exceeded exception that is generated on large soap messages:
http://craigrandall.net/archives/2009/04/maxreceivedmessagesize/
Quick summary: update the values in the binding in the app.config file.
]]></description>
			<content:encoded><![CDATA[<p>Just found a solution to the max message size exceeded exception that is generated on large soap messages:</p>
<p>http://craigrandall.net/archives/2009/04/maxreceivedmessagesize/</p>
<p>Quick summary: update the values in the binding in the app.config file.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2009/10/soap-client-max-message-size/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force UNC Path</title>
		<link>http://andrew.lowe.id.au/blog/2009/10/force-unc-path/</link>
		<comments>http://andrew.lowe.id.au/blog/2009/10/force-unc-path/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 03:42:28 +0000</pubDate>
		<dc:creator>alowe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[unc]]></category>

		<guid isPermaLink="false">http://andrew.lowe.id.au/blog/?p=65</guid>
		<description><![CDATA[Sometimes an application needs to save the path to a file, using only UNC path.  Here I describe how to do this...]]></description>
			<content:encoded><![CDATA[<p>Some applications I have written have data files that are required to be opened by multiple users on different computers. Â¬â€ These data files are, of course, stored on a common file server.</p>
<p>Usually the user doing the data-entry will have the path mapped as a network drive such as &#8220;u:\&#8221;.Â¬â€ The people who need to look at the data files may not have the drive mapped, or may have it mapped as a different drive letter.Â¬â€ The solution is to store the path as a Uniform Naming Convention (UNC) path, such as: &#8220;\\myserver\datafiles\&#8221;</p>
<p>The quick solution, is when they type the path, just check the string starts with &#8220;\\\\&#8221; (we check that there are two backslash characters: &#8220;\&#8221;, however because this is a special character we need to escape it with a backslash). Â¬â€ This way we know it will be a network path.</p>
<p>Usually a user will want to browse to the directory or file, and you would use the standard .Net widgets for these tasks. Â¬â€ The data-entry user will usually have the path mapped as a network drive and try to browse to that, and you checks will detect that the string stored does not start with &#8220;\\\\&#8221;, but rather &#8220;u:\&#8221; and display an error to the user. Â¬â€ This is not very productive to the user, who will have to work out how to fix the problem, if they even understand the problem.</p>
<p>What we need is a method to re-map the mapped network drive to the full UNC path, and this is provided bellow:</p>
<pre name="code" class="c#">public string getUNCPath(string sFilePath)
{
  if (sFilePath == string.Empty || sFilePath.StartsWith("\\\\"))
    return sFilePath;
  System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher("SELECT RemoteName FROM win32_NetworkConnection WHERE LocalName = '" + sFilePath.Substring(0, 2) + "'");
  foreach (System.Management.ManagementObject managementObject in searcher.Get())
  {
    string sRemoteName = managementObject["RemoteName"] as string;
    sRemoteName += sFilePath.Substring(2);
    return sRemoteName;
   }
   return sFilePath;
}</pre>
<p>After this, a simple check to make sure the string starts with &#8220;\\\\&#8221; is sufficient to verify that you are storing a UNC path.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrew.lowe.id.au/blog/2009/10/force-unc-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

