<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Jason Niver's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/jasonn/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/jasonn/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:03:27 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SQL Server Index Maintenance</title>
      <link>https://docs.microsoft.com/archive/blogs/jasonn/sql-server-index-maintenance</link>
      <pubDate>Tue, 04 Nov 2008 15:09:17 GMT</pubDate>
      <dc:creator><![CDATA[jniver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jasonn/2008/11/04/sql-server-index-maintenance/</guid>
      <description><![CDATA[After working on a problem where the transaction logs for a large database were filling to sizes...]]></description>
      <content:encoded><![CDATA[<p>After working on a problem where the transaction logs for a large database were filling to sizes larger then the actual database every night it turned out to be a server maintenance plan that rebuilt and reorganized indexes every night.&nbsp; While working on designing a custom plan that would only rebuild or reorganize when actually necessary I found many references out on the internet.&nbsp; None of the scripts I found out there really accomplished what I was after.</p> <p>Starting with finding the indexes that need maintenance done on them I eventually came up with this SQL:</p> <div class="csharpcode"><pre class="alt"><span class="kwrd">select</span> </pre><pre>    sch.name [schema_name]</pre><pre class="alt">    ,obj.name [table_name]</pre><pre>    ,idx.name [index_name]</pre><pre class="alt">    ,idx.type_desc [index_type]</pre><pre>    ,part.used_page_count*8 [used_kb] --<span class="kwrd">each</span> page <span class="kwrd">is</span> 8k</pre><pre class="alt">    ,part.row_count</pre><pre>    ,<span class="kwrd">CONVERT</span>(<span class="kwrd">DECIMAL</span>(9,2),frag.avg_fragmentation_in_percent) [fragmentation]</pre><pre class="alt">    <span class="kwrd">from</span> sys.dm_db_partition_stats part</pre><pre>        <span class="kwrd">join</span> sys.objects obj <span class="kwrd">on</span> part.object_id = obj.object_id</pre><pre class="alt">        <span class="kwrd">join</span> sys.schemas sch <span class="kwrd">on</span> obj.schema_id = sch.schema_id</pre><pre>        <span class="kwrd">left</span> <span class="kwrd">join</span> sys.indexes idx <span class="kwrd">on</span> part.object_id = idx.object_id <span class="kwrd">and</span> part.index_id = idx.index_id</pre><pre class="alt">        <span class="kwrd">left</span> <span class="kwrd">join</span> sys.dm_db_index_physical_stats(db_id(),<span class="kwrd">null</span>,<span class="kwrd">null</span>,<span class="kwrd">null</span>,<span class="kwrd">null</span>) frag <span class="kwrd">on</span> part.object_id = frag.object_id</pre><pre>            <span class="kwrd">and</span> part.index_id = frag.index_id</pre><pre class="alt">    <span class="kwrd">where</span> </pre><pre>        obj.is_ms_shipped = 0</pre><pre class="alt">        <span class="kwrd">and</span> frag.page_count &gt; 100</pre><pre>    <span class="kwrd">order</span> <span class="kwrd">by</span> [schema_name],[table_name],[index_name];</pre><pre><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style></pre></div>
<p>This gave me a nice view to see how big the tables were, and where the fragmentation problems were.&nbsp; We decided that if it's less800KB (based on frag.page_count) we didn't care about the fragmentation.</p>
<p>Armed with this info it was a matter of basically executing the rebuild or reorganize depending on your preference.&nbsp; I decided to use a in memory table and just did a insert-select into it.&nbsp; My temp table looked like:</p>
<div class="csharpcode"><pre class="alt"><span class="kwrd">declare</span> @IndexStatus <span class="kwrd">table</span>(</pre><pre>    schema_name <span class="kwrd">varchar</span>(250)</pre><pre class="alt">    ,table_name <span class="kwrd">varchar</span>(250)</pre><pre>    ,index_name <span class="kwrd">varchar</span>(250)</pre><pre class="alt">    ,index_type <span class="kwrd">varchar</span>(250)</pre><pre>    ,used_kb <span class="kwrd">int</span></pre><pre class="alt">    ,row_count <span class="kwrd">int</span></pre><pre>    ,fragmentation <span class="kwrd">decimal</span>(9,2));</pre></div>
<p>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</p>
<p>From there I just took the results into a cursor and executed dynamic sql.&nbsp; My logic was &lt;10% fragmentation I didn't care, greater then 30 gets a rebuild, 10-30 gets a reorganize</p>
<div class="csharpcode"><pre class="alt"><span class="kwrd">declare</span> maintCursor <span class="kwrd">cursor</span> <span class="kwrd">for</span></pre><pre>    <span class="kwrd">select</span> <span class="str">'alter index ['</span>+[index_name]+<span class="str">'] on ['</span>+[schema_name]+<span class="str">'].['</span>+[table_name]+<span class="str">']'</span>, fragmentation </pre><pre class="alt">        <span class="kwrd">from</span> @IndexStatus </pre><pre>        <span class="kwrd">where</span> fragmentation &gt; 10;</pre><pre class="alt">&nbsp;</pre><pre><span class="kwrd">declare</span> @stmt <span class="kwrd">varchar</span>(<span class="kwrd">max</span>);</pre><pre class="alt"><span class="kwrd">declare</span> @frag <span class="kwrd">float</span>;</pre><pre>&nbsp;</pre><pre class="alt"><span class="kwrd">open</span> maintCursor</pre><pre><span class="kwrd">fetch</span> <span class="kwrd">next</span> <span class="kwrd">from</span> maintCursor <span class="kwrd">into</span> @stmt, @frag</pre><pre class="alt"><span class="kwrd">while</span> <span class="preproc">@@fetch_status</span> = 0</pre><pre><span class="kwrd">begin</span></pre><pre class="alt">    <span class="kwrd">if</span> @frag &gt; 30</pre><pre>        <span class="kwrd">set</span> @stmt = @stmt+<span class="str">' rebuild'</span>; --<span class="kwrd">if</span> this <span class="kwrd">is</span> enterprise you can <span class="kwrd">add</span> <span class="str">'with (online=on)'</span></pre><pre class="alt">    <span class="kwrd">else</span></pre><pre>        <span class="kwrd">set</span> @stmt = @stmt+<span class="str">' reorganize'</span>;</pre><pre class="alt">    </pre><pre>    <span class="kwrd">print</span> (@stmt)</pre><pre class="alt">    <span class="kwrd">exec</span> (@stmt)</pre><pre>    <span class="kwrd">fetch</span> <span class="kwrd">next</span> <span class="kwrd">from</span> maintCursor <span class="kwrd">into</span> @stmt, @frag</pre><pre class="alt"><span class="kwrd">end</span></pre><pre><span class="kwrd">close</span> maintCursor</pre><pre class="alt"><span class="kwrd">deallocate</span> maintCursor</pre></div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>]]></content:encoded>
    </item>
    <item>
      <title>Sending Encrypted E-Mails in C#</title>
      <link>https://docs.microsoft.com/archive/blogs/jasonn/sending-encrypted-e-mails-in-c</link>
      <pubDate>Mon, 18 Aug 2008 18:14:26 GMT</pubDate>
      <dc:creator><![CDATA[jniver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jasonn/2008/08/18/sending-encrypted-e-mails-in-c/</guid>
      <description><![CDATA[So I was faced with the problem of sending an encrypted email to a group of people.&nbsp; Not really...]]></description>
      <content:encoded><![CDATA[<p>So I was faced with the problem of sending an encrypted email to a group of people.&nbsp; Not really thinking, I responded with sure we can do that no problem. Getting back to my desk I started working on the project to find out that it turns out to be more difficult then I had thought.</p> <p>Doing some internet searches, I found several commercial products that allow you to encrypt emails.&nbsp; I also found several discussions where people got close to what they were after, most were just after digital signatures without attachments.&nbsp; Nothing close to a full package.</p> <p>After a few hours worth of digging I finally was able to come up with a solution that met my needs, multiple addressees and multiple attachments.&nbsp; Below is the code, note that you need to add a reference to System.Security in your Visual Studio Project to compile this code.</p> <p>&nbsp;</p><!-- code formatted by https://manoli.net/csharpformat/ --> <style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}

.csharpcode pre { margin: 0em; }

.csharpcode .rem { color: #008000; }

.csharpcode .kwrd { color: #0000ff; }

.csharpcode .str { color: #006080; }

.csharpcode .op { color: #0000c0; }

.csharpcode .preproc { color: #cc6633; }

.csharpcode .asp { background-color: #ffff00; }

.csharpcode .html { color: #800000; }

.csharpcode .attr { color: #ff0000; }

.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}

.csharpcode .lnum { color: #606060; }
</style>  <div class="csharpcode"><pre class="alt"><span class="kwrd">using</span> System;</pre><pre><span class="kwrd">using</span> System.Text;</pre><pre class="alt"><span class="kwrd">using</span> System.Net.Mail;</pre><pre><span class="kwrd">using</span> System.IO;</pre><pre class="alt"><span class="kwrd">using</span> System.Security.Cryptography.Pkcs;</pre><pre><span class="kwrd">using</span> System.Security.Cryptography.X509Certificates;</pre><pre class="alt">&nbsp;</pre><pre><span class="kwrd">namespace</span> CommonUtilities</pre><pre class="alt">{</pre><pre>    <span class="rem">//requires reference to System.Security</span></pre><pre class="alt">    <span class="kwrd">class</span> EmailUtil</pre><pre>    {</pre><pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SendEncryptedEmail(<span class="kwrd">string</span>[] to, <span class="kwrd">string</span> from, <span class="kwrd">string</span> subject, <span class="kwrd">string</span> body, <span class="kwrd">string</span>[] attachments)</pre><pre>        {</pre><pre class="alt">            MailMessage message = <span class="kwrd">new</span> MailMessage();</pre><pre>            message.From = <span class="kwrd">new</span> MailAddress(from);</pre><pre class="alt">            message.Subject = subject;</pre><pre>&nbsp;</pre><pre class="alt">            <span class="kwrd">if</span> (attachments != <span class="kwrd">null</span> &amp;&amp; attachments.Length &gt; 0)</pre><pre>            {</pre><pre class="alt">                StringBuilder buffer = <span class="kwrd">new</span> StringBuilder();</pre><pre>                buffer.Append(<span class="str">"MIME-Version: 1.0\r\n"</span>);</pre><pre class="alt">                buffer.Append(<span class="str">"Content-Type: multipart/mixed; boundary=unique-boundary-1\r\n"</span>);</pre><pre>                buffer.Append(<span class="str">"\r\n"</span>);</pre><pre class="alt">                buffer.Append(<span class="str">"This is a multi-part message in MIME format.\r\n"</span>);</pre><pre>                buffer.Append(<span class="str">"--unique-boundary-1\r\n"</span>);</pre><pre class="alt">                buffer.Append(<span class="str">"Content-Type: text/plain\r\n"</span>);  <span class="rem">//could use text/html as well here if you want a html message</span></pre><pre>                buffer.Append(<span class="str">"Content-Transfer-Encoding: 7Bit\r\n\r\n"</span>);</pre><pre class="alt">                buffer.Append(body);</pre><pre>                <span class="kwrd">if</span> (!body.EndsWith(<span class="str">"\r\n"</span>))</pre><pre class="alt">                    buffer.Append(<span class="str">"\r\n"</span>);</pre><pre>                buffer.Append(<span class="str">"\r\n\r\n"</span>);</pre><pre class="alt">&nbsp;</pre><pre>                <span class="kwrd">foreach</span> (<span class="kwrd">string</span> filename <span class="kwrd">in</span> attachments)</pre><pre class="alt">                {</pre><pre>                    FileInfo fileInfo = <span class="kwrd">new</span> FileInfo(filename);</pre><pre class="alt">                    buffer.Append(<span class="str">"--unique-boundary-1\r\n"</span>);</pre><pre>                    buffer.Append(<span class="str">"Content-Type: application/octet-stream; file="</span> + fileInfo.Name + <span class="str">"\r\n"</span>);</pre><pre class="alt">                    buffer.Append(<span class="str">"Content-Transfer-Encoding: base64\r\n"</span>);</pre><pre>                    buffer.Append(<span class="str">"Content-Disposition: attachment; filename="</span> + fileInfo.Name + <span class="str">"\r\n"</span>);</pre><pre class="alt">                    buffer.Append(<span class="str">"\r\n"</span>);</pre><pre>                    <span class="kwrd">byte</span>[] binaryData = File.ReadAllBytes(filename);</pre><pre class="alt">&nbsp;</pre><pre>                    <span class="kwrd">string</span> base64Value = Convert.ToBase64String(binaryData, 0, binaryData.Length);</pre><pre class="alt">                    <span class="kwrd">int</span> position = 0;</pre><pre>                    <span class="kwrd">while</span> (position &lt; base64Value.Length)</pre><pre class="alt">                    {</pre><pre>                        <span class="kwrd">int</span> chunkSize = 100;</pre><pre class="alt">                        <span class="kwrd">if</span> (base64Value.Length - (position + chunkSize) &lt; 0)</pre><pre>                            chunkSize = base64Value.Length - position;</pre><pre class="alt">                        buffer.Append(base64Value.Substring(position, chunkSize));</pre><pre>                        buffer.Append(<span class="str">"\r\n"</span>);</pre><pre class="alt">                        position += chunkSize;</pre><pre>                    }</pre><pre class="alt">                    buffer.Append(<span class="str">"\r\n"</span>);</pre><pre>                }</pre><pre class="alt">&nbsp;</pre><pre>                body = buffer.ToString();</pre><pre class="alt">            }</pre><pre>            <span class="kwrd">else</span></pre><pre class="alt">            {</pre><pre>                body = <span class="str">"Content-Type: text/plain\r\nContent-Transfer-Encoding: 7Bit\r\n\r\n"</span> + body;</pre><pre class="alt">            }</pre><pre>&nbsp;</pre><pre class="alt">            <span class="kwrd">byte</span>[] messageData = Encoding.ASCII.GetBytes(body);</pre><pre>            ContentInfo content = <span class="kwrd">new</span> ContentInfo(messageData);</pre><pre class="alt">            EnvelopedCms envelopedCms = <span class="kwrd">new</span> EnvelopedCms(content);</pre><pre>            CmsRecipientCollection toCollection = <span class="kwrd">new</span> CmsRecipientCollection();</pre><pre class="alt">            <span class="kwrd">foreach</span> (<span class="kwrd">string</span> address <span class="kwrd">in</span> to)</pre><pre>            {</pre><pre class="alt">                message.To.Add(<span class="kwrd">new</span> MailAddress(address));</pre><pre>                X509Certificate2 certificate = <span class="kwrd">null</span>; <span class="rem">//Need to load from store or from file the client's cert</span></pre><pre class="alt">                CmsRecipient recipient = <span class="kwrd">new</span> CmsRecipient(SubjectIdentifierType.SubjectKeyIdentifier, certificate);</pre><pre>                toCollection.Add(recipient);</pre><pre class="alt">            }</pre><pre>&nbsp;</pre><pre class="alt">            envelopedCms.Encrypt(toCollection);</pre><pre>            <span class="kwrd">byte</span>[] encryptedBytes = envelopedCms.Encode();</pre><pre class="alt">&nbsp;</pre><pre>            <span class="rem">//add digital signature:</span></pre><pre class="alt">            SignedCms signedCms = <span class="kwrd">new</span> SignedCms(<span class="kwrd">new</span> ContentInfo(encryptedBytes));</pre><pre>            X509Certificate2 signerCertificate = <span class="kwrd">null</span>; <span class="rem">//Need to load from store or from file the signer's cert</span></pre><pre class="alt">            CmsSigner signer = <span class="kwrd">new</span> CmsSigner(SubjectIdentifierType.SubjectKeyIdentifier, signerCertificate);</pre><pre>            signedCms.ComputeSignature(signer);</pre><pre class="alt">            encryptedBytes = signedCms.Encode();</pre><pre>            <span class="rem">//end digital signature section</span></pre><pre class="alt">&nbsp;</pre><pre>            MemoryStream stream = <span class="kwrd">new</span> MemoryStream(encryptedBytes);</pre><pre class="alt">            AlternateView view = <span class="kwrd">new</span> AlternateView(stream, <span class="str">"application/pkcs7-mime; smime-type=signed-data;name=smime.p7m"</span>);</pre><pre>            message.AlternateViews.Add(view);</pre><pre class="alt">&nbsp;</pre><pre>            SmtpClient client = <span class="kwrd">new</span> SmtpClient(<span class="str">"your.smtp.mailhost"</span>);</pre><pre class="alt">            <span class="rem">//add authentication info if required by your smtp server etc...</span></pre><pre>            <span class="rem">//client.Credentials = CredentialCache.DefaultCredentials;</span></pre><pre class="alt">            client.Send(message);</pre><pre>        }</pre><pre class="alt">    }</pre><pre>}</pre><pre>&nbsp;</pre></div>
<p>This should get you pretty much everything you need. The only thing left is to load the certificates from somewhere.&nbsp; I used a function to load them from the current users certificate store on the machine.&nbsp; I have a previous blog posting on <a href="https://blogs.msdn.com/jasonn/archive/2008/07/16/using-certificates-from-the-windows-certificate-store.aspx">how to load the certificates from the store</a>.&nbsp; The trick comes in to fetching the certificates for unknown parties etc.&nbsp; ]]></content:encoded>
    </item>
    <item>
      <title>Using certificates from the Windows certificate store</title>
      <link>https://docs.microsoft.com/archive/blogs/jasonn/using-certificates-from-the-windows-certificate-store</link>
      <pubDate>Wed, 16 Jul 2008 14:15:00 GMT</pubDate>
      <dc:creator><![CDATA[jniver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jasonn/2008/07/16/using-certificates-from-the-windows-certificate-store/</guid>
      <description><![CDATA[I recently had to setup some web services that used certificates to communicate back and forth and...]]></description>
      <content:encoded><![CDATA[<p>I recently had to setup some web services that used certificates to communicate back and forth and one thing I found is that pretty much every site I found references on was using a file on the file system to access the client certificate.&nbsp; What we wanted to do was access the certificates directly from the store.&nbsp; After a little playing around we got it to work, so I though I would put this out in case someone else wants to do the same.&nbsp; There is another X509Certificate2Collection item at MSDN, however the one for the X509Certificate2 only shows getting the file.</p><p>Assuming:<br>using System.Security.Cryptography.X509Certificates;</p><p>private X509Certificate GetCertificate()<br>{<br>&nbsp;&nbsp;&nbsp; X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);<br>&nbsp;&nbsp;&nbsp; store.Open(OpenFlags.ReadOnly);<br>&nbsp;&nbsp;&nbsp; X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindBySerialNumber, "123456", true);<br>&nbsp;&nbsp;&nbsp; store.Close();<br>&nbsp;&nbsp;&nbsp; return certs[0];<br>} <br></p><p>There are several ways to do the search, I like the FindBySerialNumber, but you can also search by DN, SubjectName, etc.&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Downloading files from the internet in PowerShell (with progress)</title>
      <link>https://docs.microsoft.com/archive/blogs/jasonn/downloading-files-from-the-internet-in-powershell-with-progress</link>
      <pubDate>Fri, 13 Jun 2008 09:42:00 GMT</pubDate>
      <dc:creator><![CDATA[jniver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jasonn/2008/06/13/downloading-files-from-the-internet-in-powershell-with-progress/</guid>
      <description><![CDATA[Ok, so the easiest way (that I know of) to download files in powershell from the internet is to use...]]></description>
      <content:encoded><![CDATA[<P>Ok, so the <SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">easiest </SPAN>way (that I know of) to download files in powershell from the internet is to use the .net WebClient.&nbsp; The simple way I started with was the two liner:</P>
<P><FONT color=#800080>$client</FONT><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> <SPAN style="COLOR: #5f9ea0">New-Object</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800000">"System.Net.WebClient"<BR><FONT color=#800080>$client.DownloadFile("https://somesite.com/largefile.zip","c:\temp\largefile.zip"</FONT></SPAN></SPAN></P>
<P><SPAN style="COLOR: #000000"><SPAN style="COLOR: #800000"></SPAN></SPAN>However I was working on a script that required some pretty large files to be downloaded, and using the DownloadFile method has no progress indicator.&nbsp; I figured some users might thing the program died.&nbsp; So I decided to create a method that still uses the webclient to download the files, however give a status of where it is in the download.&nbsp; Here is what I came up with, hopefully someone else will find it useful.</P>
<P mce_keep="true"><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">downloadFile</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #800080">$url</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$targetFile</SPAN><SPAN style="COLOR: #000000">)<BR>{ </SPAN><SPAN style="COLOR: #800000"><BR>&nbsp;&nbsp;&nbsp; "Downloading $url"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $uri</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #5f9ea0">New-Object</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800000">"System.Uri"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800000">"$url"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $request</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> [</SPAN><SPAN style="COLOR: #8b4513">System.Net.HttpWebRequest</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">::</SPAN><SPAN style="COLOR: #8b4513">Create</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #800080">$uri</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $request</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">set_Timeout</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">15000</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #008000">#15 second timeout </SPAN><SPAN style="COLOR: #000000"></SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $response</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$request</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">GetResponse</SPAN><SPAN style="COLOR: #000000">() </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $totalLength</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> [</SPAN><SPAN style="COLOR: #8b4513">System.Math</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">::</SPAN><SPAN style="COLOR: #8b4513">Floor</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #800080">$response</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">get_ContentLength</SPAN><SPAN style="COLOR: #000000">()</SPAN><SPAN style="COLOR: #ff0000">/</SPAN><SPAN style="COLOR: #000000">1024</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $responseStream</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$response</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">GetResponseStream</SPAN><SPAN style="COLOR: #000000">() </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $targetStream</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #5f9ea0">New-Object</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #5f9ea0">-TypeName</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #8b4513">System.IO.FileStream</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #5f9ea0">-ArgumentList</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$targetFile</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">Create</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $buffer</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #5f9ea0">new-object</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[] </SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #0000ff">KB</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $count</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$responseStream</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">Read</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #800080">$buffer</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800080">$buffer</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">length</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $downloadedBytes</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$count</SPAN><SPAN style="COLOR: #000000"> <BR>&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #800080">$count</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">-gt</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">) <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [</SPAN><SPAN style="COLOR: #8b4513">System.Console</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">::</SPAN><SPAN style="COLOR: #8b4513">CursorLeft</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000"> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [</SPAN><SPAN style="COLOR: #8b4513">System.Console</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">::</SPAN><SPAN style="COLOR: #8b4513">Write</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #800000">"Downloaded {0}K of {1}K"</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> [</SPAN><SPAN style="COLOR: #8b4513">System.Math</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">::</SPAN><SPAN style="COLOR: #8b4513">Floor</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #800080">$downloadedBytes</SPAN><SPAN style="COLOR: #ff0000">/</SPAN><SPAN style="COLOR: #000000">1024</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$totalLength</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $targetStream</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">Write</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #800080">$buffer</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$count</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $count</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$responseStream</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">Read</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #800080">$buffer</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800080">$buffer</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">length</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $downloadedBytes</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$downloadedBytes</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #ff0000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080">$count</SPAN><SPAN style="COLOR: #000000"> <BR>&nbsp;&nbsp;&nbsp; } </SPAN><SPAN style="COLOR: #800000"><BR>&nbsp;&nbsp;&nbsp; "`nFinished Download"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800080"><BR>&nbsp;&nbsp;&nbsp; $targetStream</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">Flush</SPAN><SPAN style="COLOR: #000000">()</SPAN><BR><SPAN class=style1>&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #800080">$targetStream</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">Close</SPAN><SPAN style="COLOR: #000000">() <BR>&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #800080">$targetStream</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">Dispose</SPAN><SPAN style="COLOR: #000000">() <BR>&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #800080">$responseStream</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #8b4513">Dispose</SPAN><SPAN style="COLOR: #000000">() <BR>} </SPAN></P>
<P mce_keep="true"><SPAN style="COLOR: #000000">This would be used like<BR>downloadFile "https://somesite/largefile.zip" "c:\temp\largefile.zip"</SPAN></P>
<P mce_keep="true"><SPAN style="COLOR: #000000"></SPAN>&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Importing a File Share into Document Library via PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/jasonn/importing-a-file-share-into-document-library-via-powershell</link>
      <pubDate>Wed, 21 May 2008 21:24:53 GMT</pubDate>
      <dc:creator><![CDATA[jniver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jasonn/2008/05/21/importing-a-file-share-into-document-library-via-powershell/</guid>
      <description><![CDATA[So today I was asked for a way to automate importing files from a file share into a document...]]></description>
      <content:encoded><![CDATA[<p>So today I was asked for a way to automate importing files from a file share into a document library.&#160; For this, ACL's were not an issue, however using PS's Get-ACL function can get you that as well to match the insert.</p>  <p>Here is what I came up with as a quick and dirty response.&#160; I though it might be nice to post for other people to use as a base script for things like synchronizing file shares with document libraries etc.</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">#Variables</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$targetLibrary = <span style="color: #006080">&quot;Imported Documents&quot;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$sourceDirectory = <span style="color: #006080">&quot;\\somemachine\someshare&quot;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$siteUrl = <span style="color: #006080">&quot;https://localhost/sites/somesite&quot;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">#open the SPWeb/SPSite</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">[System.Reflection.Assembly]::LoadWithPartialName(<span style="color: #006080">&quot;Microsoft.SharePoint&quot;</span>)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$site = New-Object <span style="color: #006080">&quot;Microsoft.SharePoint.SPSite&quot;</span> $siteUrl</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$web = $site.OpenWeb()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">#get all the files and directories on the share and iterate them</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">foreach</span> ($file <span style="color: #0000ff">in</span> get-childitem $sourceDirectory -recurse)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    $fileName = ($file | Select-Object Name).Name    #get the <span style="color: #0000ff">base</span> file nname</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    $parentPath = ($file | Select-Object PSParentPath) #get the path</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    #eliminate everything <span style="color: #0000ff">in</span> the path prior to the root folder</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    $parentPath = $parentPath.Substring($parentPath.PSParentPath.ToLower().IndexOf($sourceDirectory.ToLower())+$sourceDirectory.Length)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    $parentPath = $parentPath.Replace(<span style="color: #006080">&quot;\&quot;,&quot;</span>/<span style="color: #006080">&quot;)    #make the path url friendly</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    $targetPath = &quot;</span>/$targetLibrary$parentPath/$fileName<span style="color: #006080">&quot; #combine for a full url</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    #check if this is a directory or file</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    if (($file.GetType() | Select-Object Name).Name -eq &quot;</span>DirectoryInfo<span style="color: #006080">&quot;)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        &quot;</span>Adding Folder: $targetPath<span style="color: #006080">&quot;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        $web.get_Folders().Add($targetPath)    </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    else</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        $parentFile = ($file | Select-Object FullName).FullName #gets the full path to the file</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        &quot;</span>Adding File: $targetPath<span style="color: #006080">&quot;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        $fileBytes = [System.IO.File]::OpenRead(&quot;</span>$parentFile&quot;) #read the file to a <span style="color: #0000ff">byte</span> arry</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        $web.get_Files().Add($targetPath,$fileBytes)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">}</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">#dispose of the web/site</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$web.Dispose()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$site.Dispose()</pre>
  </div>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Web Parts the Simple Way - Use User Controls</title>
      <link>https://docs.microsoft.com/archive/blogs/jasonn/web-parts-the-simple-way-use-user-controls</link>
      <pubDate>Tue, 13 May 2008 09:39:00 GMT</pubDate>
      <dc:creator><![CDATA[jniver]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jasonn/2008/05/13/web-parts-the-simple-way-use-user-controls/</guid>
      <description><![CDATA[One of the first questions I usually get about SharePoint development is how to make the WebPart...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">One of the first questions I usually get about SharePoint development is how to make the WebPart development process simpler.&nbsp; My answer to that is use UserControls.&nbsp; There is a very good solution on CodePlex called Smart Parts <A href="https://www.codeplex.com/smartpart" mce_href="https://www.codeplex.com/smartpart">https://www.codeplex.com/smartpart</A>&nbsp; However I have found in some environments the customer does not want to add a third party product into the mix.&nbsp; In these cases the fastest way I have found to create webparts is to use user controls and wrap them with the webpart.</SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN>&nbsp;</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">We start with a very simple WebPart class that only overrides the CreateChildControls method, we use this to load our user control.</SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN>&nbsp;</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">public</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">InboxListWebPart</SPAN>: <SPAN style="COLOR: #2b91af">WebPart<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: #2b91af">Control</SPAN> control = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">protected</SPAN> <SPAN style="COLOR: blue">override</SPAN> <SPAN style="COLOR: blue">void</SPAN> CreateChildControls()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; {<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Controls.Clear();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; control = <SPAN style="COLOR: blue">this</SPAN>.Page.LoadControl(<SPAN style="COLOR: #a31515">"/_controltemplates/MyCustomControls/InboxListControl.ascx"</SPAN>);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Controls.Add(control);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; }<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">From there everything is driven from my usercontrol InboxListControl.ascx.&nbsp; The control goes into the program files\common files\microsoft shared\web server extensions\12\templates\controltemplates directory (as shown above I created a sub directory called MyCustomControls).&nbsp; I usually will deploy the code behind into the GAC, but they can be deployed into the same directory as well.<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">If you need to do more advanced webpart stuff (like connections or properties) you can get to your webpart from your user control.&nbsp; For example if I had a property that I wanted to present to the user (say like Inbox Name) in my .cs file for the webpart I would do the following (using the 3.5 property syntax):<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">[<SPAN style="COLOR: #2b91af">Personalizable</SPAN>(<SPAN style="COLOR: #2b91af">PersonalizationScope</SPAN>.User), <SPAN style="COLOR: #2b91af">WebBrowsable</SPAN>(<SPAN style="COLOR: blue">true</SPAN>), <SPAN style="COLOR: #2b91af">WebDisplayName</SPAN>(<SPAN style="COLOR: #a31515">"Inbox Name"</SPAN>), <SPAN style="COLOR: #2b91af">WebDescription</SPAN>(<SPAN style="COLOR: #a31515">"some useful description"</SPAN>)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">public</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <SPAN style="COLOR: blue">string</SPAN> InboxName<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">get</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">set</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">In my user control I usually define a parent webpart property that returns the webpart I used to wrap my user control:<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">private</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <SPAN style="COLOR: #2b91af">InboxListWebPart</SPAN> ParentWebPart<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">get<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; {<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">this</SPAN>.Parent <SPAN style="COLOR: blue">as</SPAN> <SPAN style="COLOR: #2b91af">InboxListWebPart</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; }<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">From here I can now define my InboxName on my user control:<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">public</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <SPAN style="COLOR: #2b91af">String</SPAN> InboxName<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">get<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; {<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">return</SPAN> ParentWebPart.InboxName;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; }<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">set<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; {<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ParentWebPart.InboxName = <SPAN style="COLOR: blue">value</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp; }<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">It takes a little more code when you want to do things like properties and connections, but I think the usability of having your UI in an ascx file more then makes up for this small inconvenience.<o:p></o:p></SPAN></P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
  </channel>
</rss>