<?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>chillijam.co.uk &#187; C# Snippets</title>
	<atom:link href="http://chillijam.co.uk/category/c-snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://chillijam.co.uk</link>
	<description></description>
	<lastBuildDate>Thu, 20 May 2010 08:00:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Split a Camel-Cased word into its components</title>
		<link>http://chillijam.co.uk/2010/05/20/split-a-camel-cased-word-into-its-components/</link>
		<comments>http://chillijam.co.uk/2010/05/20/split-a-camel-cased-word-into-its-components/#comments</comments>
		<pubDate>Thu, 20 May 2010 08:00:03 +0000</pubDate>
		<dc:creator>Marc</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C# Snippets]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://chillijam.co.uk/?p=304</guid>
		<description><![CDATA[I needed to split a camel-cased word into it&#8217;s component parts, and found the following extension method to help out.  It works pretty well. public static string SplitCamelCase( this string str ) { return Regex.Replace( Regex.Replace( str, @&#34;(\P{Ll})(\P{Ll}\p{Ll})&#34;, &#34;$1 $2&#34; &#8230; <a href="http://chillijam.co.uk/2010/05/20/split-a-camel-cased-word-into-its-components/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I needed to split a camel-cased word into it&#8217;s component parts, and found the following extension method to help out.  It works pretty well.</p>
<pre class="brush: csharp;">
public static string SplitCamelCase( this string str )
{
return Regex.Replace( Regex.Replace( str, @&quot;(\P{Ll})(\P{Ll}\p{Ll})&quot;, &quot;$1 $2&quot; ), @&quot;(\p{Ll})(\P{Ll})&quot;, &quot;$1 $2&quot; );
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2010/05/20/split-a-camel-cased-word-into-its-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apostrophe In RowFilter</title>
		<link>http://chillijam.co.uk/2006/09/25/apostrophe-in-rowfilter/</link>
		<comments>http://chillijam.co.uk/2006/09/25/apostrophe-in-rowfilter/#comments</comments>
		<pubDate>Mon, 25 Sep 2006 16:05:08 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[C# Snippets]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/1999/11/30/apostrophe-in-rowfilter/</guid>
		<description><![CDATA[According to ASP.NET Resources, there is a problem when using apostrophes in a RowFilter expression in a DataView. The fix seems to be to double the apostrophes (&#8220;O&#8221;Mally&#8221;) rather than escaping them (&#8220;O\&#8217;Mally&#8221;)]]></description>
			<content:encoded><![CDATA[<p>According to <a href="http://www.aspnetresources.com/blog/apostrophe_in_rowfilter.aspx">ASP.NET Resources</a>, there is a problem when using apostrophes in a RowFilter expression in a DataView.  The fix seems to be to double the apostrophes (&#8220;O&#8221;Mally&#8221;) rather than escaping them (&#8220;O\&#8217;Mally&#8221;)</p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2006/09/25/apostrophe-in-rowfilter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iterate through enum values</title>
		<link>http://chillijam.co.uk/2006/08/30/iterate-through-enum-values/</link>
		<comments>http://chillijam.co.uk/2006/08/30/iterate-through-enum-values/#comments</comments>
		<pubDate>Wed, 30 Aug 2006 11:16:28 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C# Snippets]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/2006/08/30/iterate-through-enum-values/</guid>
		<description><![CDATA[A quick example of how to iterate through the values in an enum&#8230; enum myEnum { one, two, three, four, five, }; foreach (int i in Enum.GetValues(typeof(myEnum ))) { myEnum myItem = (myEnum )Enum.ToObject(typeof(myEnum ), i); System.Diagnostics.Debug.WriteLine(myItem.ToString()); }]]></description>
			<content:encoded><![CDATA[<p>A quick example of how to iterate through the values in an enum&#8230;</p>
<p><code>enum myEnum { one, two, three, four, five, };<br />
foreach (int i in Enum.GetValues(typeof(myEnum )))<br />
{<br />
  myEnum myItem = (myEnum )Enum.ToObject(typeof(myEnum ), i);<br />
  System.Diagnostics.Debug.WriteLine(myItem.ToString());<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2006/08/30/iterate-through-enum-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine if an assembly is a debug or release build</title>
		<link>http://chillijam.co.uk/2006/05/04/determine-if-an-assembly-is-a-debug-or-release-build/</link>
		<comments>http://chillijam.co.uk/2006/05/04/determine-if-an-assembly-is-a-debug-or-release-build/#comments</comments>
		<pubDate>Thu, 04 May 2006 15:47:46 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C# Snippets]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/2006/05/04/determine-if-an-assembly-is-a-debug-or-release-build/</guid>
		<description><![CDATA[*This code originally came from another blog, although it was written in VB over there. It has lost some elegance in the translation, but I needed a very quick solution this afternoon, and I needed it in C#, so here &#8230; <a href="http://chillijam.co.uk/2006/05/04/determine-if-an-assembly-is-a-debug-or-release-build/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>*This code originally came from <a href="http://msmvps.com/blogs/bill/archive/2004/06/17/8339.aspx">another blog</a>, although it was written in VB over there.  It has lost some elegance in the translation, but I needed a very quick solution this afternoon, and I needed it in C#, so here you go.  *</p>
<p>I needed to determine whether several assemblies were built as &#8220;Debug&#8221; or &#8220;Release&#8221; code this afternoon.  They didn&#8217;t have any debug symbols with them, so that was no help.  A bit of searching led me to the code below.</p>
<pre>
<pre class="brush: csharp;">private void testfile(string file)
{
	if(isAssemblyDebugBuild(file))
	{
		MessageBox.Show(String.Format(&quot;{0} seems to be a debug build&quot;,file));
	}
	else
	{
		MessageBox.Show(String.Format(&quot;{0} seems to be a release build&quot;,file));
	}
}

private bool isAssemblyDebugBuild(string filename)
{
	return isAssemblyDebugBuild(System.Reflection.Assembly.LoadFile(filename));
}

private bool isAssemblyDebugBuild(System.Reflection.Assembly assemb)
{
	bool retVal = false;
	foreach(object att in assemb.GetCustomAttributes(false))
	{
		if(att.GetType() == System.Type.GetType(&quot;System.Diagnostics.DebuggableAttribute&quot;))
		{
			retVal = ((System.Diagnostics.DebuggableAttribute)att).IsJITTrackingEnabled;
		}
	}
	return retVal;
}</pre>
</pre>
<p>The overloaded &#8220;isAssemblyDebugBuild&#8221; method will accept either a string containing the fiull filename, or a System.Reflection.Assembly object.  It will return its best guess as to whether the the assembly is a debug build, as a boolean.</p>
<p>To call the methods as they are (to get a MessageBox), just use something like</p>
<pre>
<pre class="brush: csharp;">testfile(@&quot;C:\myUnknownAssembly.dll&quot;);</pre>
</pre>
<p>or access the underlying methods directly :</p>
<pre>
<pre class="brush: csharp;">bool isDebug = isAssemblyDebugBuild(@&quot;C:\myUnkownAssembly.dll&quot;);</pre>
</pre>
<p>I hope someone can use this to save themselves some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2006/05/04/determine-if-an-assembly-is-a-debug-or-release-build/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sending an HTTP POST request to a web server</title>
		<link>http://chillijam.co.uk/2005/10/26/sending-an-http-post-request-to-a-web-server/</link>
		<comments>http://chillijam.co.uk/2005/10/26/sending-an-http-post-request-to-a-web-server/#comments</comments>
		<pubDate>Wed, 26 Oct 2005 10:20:30 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[C# Snippets]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/2005/10/26/sending-an-http-post-request-to-a-web-server/</guid>
		<description><![CDATA[ASCIIEncoding encoding = new ASCIIEncoding(); string post_url = "http://172.16.24.44/postdata.php"; string poststring = "monkeys=blue\&#38;trousers=black"; byte[] data = encoding.GetBytes(poststring); HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(post_url); httpRequest.Method = "POST"; httpRequest.ContentType="application/x-www-form-urlencoded"; httpRequest.ContentLength = data.Length; Stream newStream=httpRequest.GetRequestStream(); newStream.Write(data,0,data.Length); newStream.Close(); HttpWebResponse response = (HttpWebResponse)httpRequest.GetResponse (); Stream receiveStream = &#8230; <a href="http://chillijam.co.uk/2005/10/26/sending-an-http-post-request-to-a-web-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<pre>ASCIIEncoding encoding = new ASCIIEncoding();
string post_url = "http://172.16.24.44/postdata.php";
string poststring = "monkeys=blue\&amp;trousers=black";
byte[] data = encoding.GetBytes(poststring);

HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(post_url);
httpRequest.Method = "POST";
httpRequest.ContentType="application/x-www-form-urlencoded";
httpRequest.ContentLength = data.Length;
Stream newStream=httpRequest.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();

HttpWebResponse response = (HttpWebResponse)httpRequest.GetResponse ();
Stream receiveStream = response.GetResponseStream ();
StreamReader readStream = new StreamReader (receiveStream);
textBox1.Text = "Response stream received.";
textBox1.Text = readStream.ReadToEnd().Replace("\\n","\\r\\n");
response.Close ();
readStream.Close ();</pre>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2005/10/26/sending-an-http-post-request-to-a-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Catch key presses in a Windows Forms application</title>
		<link>http://chillijam.co.uk/2005/09/27/catch-key-presses-in-a-windows-forms-application/</link>
		<comments>http://chillijam.co.uk/2005/09/27/catch-key-presses-in-a-windows-forms-application/#comments</comments>
		<pubDate>Tue, 27 Sep 2005 09:35:03 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[C# Snippets]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/2005/09/27/catch-key-presses-in-a-windows-forms-application/</guid>
		<description><![CDATA[Simple enough to do. Set the &#8220;KeyPreview&#8221; property of the form to &#8220;True&#8221; Create a KeyUp event handler, eg private void Form1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if(e.KeyCode == Keys.F12) { // Do something here } } Wire the event handler &#8230; <a href="http://chillijam.co.uk/2005/09/27/catch-key-presses-in-a-windows-forms-application/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Simple enough to do.</p>
<ol>
<li>Set the &#8220;KeyPreview&#8221; property of the form to &#8220;True&#8221;</li>
<li>Create a KeyUp event handler, eg
<pre>private void Form1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
  if(e.KeyCode == Keys.F12)
  {
    // Do something here
  }
}</pre>
</li>
<li>Wire the event handler up to the event</li>
</ol>
<p>That is all.</p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2005/09/27/catch-key-presses-in-a-windows-forms-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharepoint portal connection strings</title>
		<link>http://chillijam.co.uk/2005/08/09/sharepoint-portal-connection-strings/</link>
		<comments>http://chillijam.co.uk/2005/08/09/sharepoint-portal-connection-strings/#comments</comments>
		<pubDate>Tue, 09 Aug 2005 16:17:21 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[C# Snippets]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/2005/08/09/sharepoint-portal-connection-strings/</guid>
		<description><![CDATA[How to pull connection string details out of a Sharepoint portal site. using System; using Microsoft.SharePoint.Portal; using Microsoft.SharePoint.Portal.Topology; namespace SPConnStrings { /// /// Summary description for Class1. /// class Class1 { /// /// The main entry point for the application. &#8230; <a href="http://chillijam.co.uk/2005/08/09/sharepoint-portal-connection-strings/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How to pull connection string details out of a Sharepoint portal site.</p>
<blockquote>
<pre>using System;
using Microsoft.SharePoint.Portal;
using Microsoft.SharePoint.Portal.Topology;

namespace SPConnStrings
{
  ///
  /// Summary description for Class1.
  ///
  class Class1
  {
    ///
    /// The main entry point for the application.
    ///
    [STAThread]
    static void Main(string[] args)
    {
      //
      // TODO: Add code to start application here
      //
      TopologyManager topology = new TopologyManager();
      PortalSite portal = topology.PortalSites[new Uri("http://cleanportal")];
      Console.WriteLine("Site db :: " + portal.SiteDatabase.SqlConnectionString.ToString());
      Console.WriteLine("Profiles db :: " + portal.UserProfileDatabase.SqlConnectionString.ToString());
      Console.WriteLine("Services db :: " + portal.ServiceDatabase.SqlConnectionString.ToString());
      Console.ReadLine();
    }
  }
}
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2005/08/09/sharepoint-portal-connection-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharepoint permissions and web parts</title>
		<link>http://chillijam.co.uk/2005/08/08/sharepoint-permissions-and-web-parts/</link>
		<comments>http://chillijam.co.uk/2005/08/08/sharepoint-permissions-and-web-parts/#comments</comments>
		<pubDate>Mon, 08 Aug 2005 10:17:01 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[C# Snippets]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/2005/08/08/sharepoint-permissions-and-web-parts/</guid>
		<description><![CDATA[There is a strong argument against doing things like this, but there are times when you just have to bite the bullet and grant full access permissions to certain web parts without having to install them to the GAC. Here&#8217;s &#8230; <a href="http://chillijam.co.uk/2005/08/08/sharepoint-permissions-and-web-parts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There is a strong argument against doing things like this, but there are times when you just have to bite the bullet and grant full access permissions to certain web parts without having to install them to the GAC.  Here&#8217;s how.</p>
<p>The first requirement for this method is that your web parts must be strong named.  I would recommend creating a new keyfile specifically for web part assembl<br />
ies that you want to fully trust.  Use the following command to do so.</p>
<pre>
<blockquote>sn.exe -k c:\keyfiles\FullTrustWebParts.snk</blockquote>
</pre>
<p>Apply this key file in the AssemblyInfo.cs file for your web part project</p>
<pre>
<blockquote>[assembly: AssemblyKeyFile(@"c:\keyfiles\FullTrustWebParts.snk")]</blockquote>
</pre>
<p>Build and deploy your project as normal.</p>
<p>Now for the fun part &#8211; configuring Sharepoint to accept the signed web parts as fully truted.</p>
<p>In the folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\CONFIG copy your wss_mediumtrust.config file to wss_trustsigned.config and then open the new file for editing.</p>
<p>Find the section that starts with the following</p>
<pre>
<blockquote>&lt;codegroup class="FirstMatchCodeGroup"
   version="1"
   PermissionSetName="Nothing"&gt;
   &lt;imembershipcondition class="AllMembershipCondition"
      version="1"
   /&amp;gt</blockquote>
</pre>
<p>and add the following immediately after this code</p>
<pre>
<blockquote>&lt;codegroup class="UnionCodeGroup"
   version="1"
   PermissionSetName="FullTrust"&gt;
      &lt;imembershipcondition class="StrongNameMembershipCondition"
         version="1"
         PublicKeyBlob="...see note below..."
      /&gt;
&lt;/codegroup&gt;</blockquote>
</pre>
<p>The test &#8220;&#8230;see code below&#8230;&#8221; needs to be replaced with the public key blob from your assembly.  To find this string, use the following command</p>
<pre>
<blockquote>secutil.exe -hex -s &lt;path to assembly&gt;</blockquote>
</pre>
<p><strong>Important : remove the leading <em>0x</em> from this string</strong></p>
<p>Save and close the new file.</p>
<p>Next, open up the Web.Config file from the root of your Sharepoint site.  In my case, this resides at c:\inetpub\wwwroot\intranet\web.config</p>
<p>In this file, find the &#8220;securityPolicy&#8221; section.  Copy one of the &#8220;trustLevel&#8221; nodes, and change the &#8220;name&#8221; attribute to &#8220;wss_trustsigned&#8221;, and also the policyFile attribute to reflect the path to your new policy file (ie. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\CONFIG\wss_trustsigned.config)</p>
<p>Once you have added the policy setting, you will need to find the &#8220;trust&#8221; node within the &#8220;system.web&#8221; section.  Change the value of the &#8220;level&#8221; attribute to &#8220;wss_trustsigned&#8221;.  This is the value you set in the previous step.</p>
<p>Now save the file, and restart IIS.  Your web parts should be fine now.</p>
<p>*NOTE* this has not been tested step by step from these instructions.  I will chek it all this week, given the chance, and make any changes that might be necessary.  I&#8217;m afraid that this is due to having to try to remember what a colleague did 12+ months ago.  Ho-hum.</p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2005/08/08/sharepoint-permissions-and-web-parts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WMI Out Of Memory issues</title>
		<link>http://chillijam.co.uk/2005/07/25/wmi-out-of-memory-issues/</link>
		<comments>http://chillijam.co.uk/2005/07/25/wmi-out-of-memory-issues/#comments</comments>
		<pubDate>Mon, 25 Jul 2005 12:52:42 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[C# Snippets]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/2005/07/25/wmi-out-of-memory-issues/</guid>
		<description><![CDATA[I have been working on an automated way of deploying BizTalk assemblies, orchestrations and bindings without having to use NAnt or MSBuild this week. It has thrown up a problem that lots of people must have if they are doing &#8230; <a href="http://chillijam.co.uk/2005/07/25/wmi-out-of-memory-issues/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been working on an automated way of deploying BizTalk assemblies, orchestrations and bindings without having to use NAnt or MSBuild this week.  It has thrown up a problem that lots of people must have if they are doing a similar thing.</p>
<p>Many times, my scripts would fail periodically, but not in predictable places.  After looking at the logs I generate, I noticed that there were a lot of &#8220;out of memory&#8221; errors caused by WMI operations.  I needed a quick fix, so I came up with this (horrible and hacky) workaround.</p>
<p>Before each section of code, restart the &#8220;winmgmt&#8221; service.  That&#8217;s it.  The scripts now work flawlessly &#8211; or at least, they fail in predictable places now.</p>
<p>**EDIT**</p>
<p>I have just been pointed towards <a href="http://geekswithblogs.net/nparker/archive/2004/10/16/12700.aspx">this page</a> which details how to increase the amount of memory available to WMI from its default of 128MB.</p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2005/07/25/wmi-out-of-memory-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Process.Start and required input</title>
		<link>http://chillijam.co.uk/2005/07/20/processstart-and-required-input/</link>
		<comments>http://chillijam.co.uk/2005/07/20/processstart-and-required-input/#comments</comments>
		<pubDate>Wed, 20 Jul 2005 16:42:01 +0000</pubDate>
		<dc:creator>historical</dc:creator>
				<category><![CDATA[C# Snippets]]></category>

		<guid isPermaLink="false">http://playingwithanimport.wordpress.com/2005/07/20/processstart-and-required-input/</guid>
		<description><![CDATA[I had an issue with Process.Start today. I was trying to call an executable that requires the user to confirm the action with a keystroke, in this case &#8220;y&#8221;. As far as I am aware, there is no mechanism within &#8230; <a href="http://chillijam.co.uk/2005/07/20/processstart-and-required-input/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had an issue with Process.Start today.  I was trying to call an executable that requires the user to confirm the action with a keystroke, in this case &#8220;y&#8221;.</p>
<p>As far as I am aware, there is no mechanism within the .NET framework to deal with this kind of thing, so I had to resort to the following syntax:</p>
<pre>
<blockquote>echo y| cacls path /E /T /P username:F</blockquote>
</pre>
<p>Unfortunately, the command &#8220;echo&#8221; is a pseudo command contained within the command shell.</p>
<p>To get around this, I had to use the following for the process.</p>
<pre>
<blockquote>Process runner = new Process();
runner.StartInfo.FileName = &quot;cmd.exe&quot;;
runner.StartInfo.Arguments = &quot;/C echo y| cacls path /E /T /P username:F&quot;;
runner.Start();
</blockquote>
</pre>
<p>There is probably a more elegant way to do this, but that&#8217;s what I came up with in the time allowed.</p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2005/07/20/processstart-and-required-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
