<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5419917401518431489</id><updated>2024-10-05T11:14:15.366+08:00</updated><category term=".NET"/><category term="C#"/><category term="programming"/><category term="web"/><category term=".NET c#"/><category term="AIX"/><category term="ASP.NET"/><category term="UNIX"/><category term="XML"/><title type='text'>dhchen&#39;s technical log</title><subtitle type='html'>Some Technical Log about information technology, including system administration, programming and network</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-3933548289347388480</id><published>2007-05-23T14:27:00.001+08:00</published><updated>2007-05-23T14:30:55.864+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET c#"/><title type='text'>Using FtpWebRequest &amp; FtpWebResponse to Upload File</title><content type='html'>&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Uri&lt;/span&gt; FtpHost = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Uri&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;ftp://127.0.0.1/wrar351.exe&quot;&lt;/span&gt;); &lt;span style=&quot;color: green;&quot;&gt;//Have to include destination filename in Uri()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;FtpWebRequest&lt;/span&gt; ftprq;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;FtpWebResponse&lt;/span&gt; ftprp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; FtpFileName=&lt;span style=&quot;color: #a31515;&quot;&gt;@&quot;c:\wrar351.exe&quot;&lt;/span&gt;; &lt;span style=&quot;color: green;&quot;&gt;//upload a WinRar self-install file&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;ftprq = (&lt;span style=&quot;color: #2b91af;&quot;&gt;FtpWebRequest&lt;/span&gt;)&lt;span style=&quot;color: #2b91af;&quot;&gt;WebRequest&lt;/span&gt;.Create(FtpHost);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;ftprq.EnableSsl = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;ftprq.UseBinary = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;ftprq.UsePassive = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;ftprq.Method = &lt;span style=&quot;color: #2b91af;&quot;&gt;WebRequestMethods&lt;/span&gt;.&lt;span style=&quot;color: #2b91af;&quot;&gt;Ftp&lt;/span&gt;.UploadFile;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;ftprq.Credentials = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;NetworkCredential&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;username&quot;&lt;/span&gt;, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;password&quot;&lt;/span&gt;);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Stream&lt;/span&gt; RequestStream = ftprq.GetRequestStream();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Put file:&quot;&lt;/span&gt; + FtpFileName);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; (&lt;span style=&quot;color: #2b91af;&quot;&gt;FileStream&lt;/span&gt; fs = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;FileStream&lt;/span&gt;(FtpFileName, &lt;span style=&quot;color: #2b91af;&quot;&gt;FileMode&lt;/span&gt;.Open))&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;{&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;[] buf = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;[4096];&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; readcount = 0;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; ((readcount = fs.Read(buf, 0, 4096)) != 0)&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; RequestStream.Write(buf, 0, readcount);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;*&quot;&lt;/span&gt;);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;}&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;RequestStream.Close();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;ftprp = (&lt;span style=&quot;color: #2b91af;&quot;&gt;FtpWebResponse&lt;/span&gt;)ftprq.GetResponse();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (ftprp.StatusCode != &lt;span style=&quot;color: #2b91af;&quot;&gt;FtpStatusCode&lt;/span&gt;.ClosingData) &lt;span style=&quot;color: green;&quot;&gt;//upload complete status is Closing Data&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;{&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;IOException&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Ftp upload Error: &quot;&lt;/span&gt; + ftprp.StatusCode.ToString() + ftprp.StatusDescription);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;}&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\nFile Upload OK\n&quot;&lt;/span&gt;);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;ftprp.Close();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/3933548289347388480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/3933548289347388480?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/3933548289347388480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/3933548289347388480'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/05/using-ftpwebrequest-ftpwebresponse-to.html' title='Using FtpWebRequest &amp; FtpWebResponse to Upload File'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-3924031514440835363</id><published>2007-05-11T10:05:00.000+08:00</published><updated>2007-05-11T10:11:46.616+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AIX"/><category scheme="http://www.blogger.com/atom/ns#" term="UNIX"/><title type='text'>Write file &gt;2G on AIX</title><content type='html'>To write file over 2G on AIX, you should check the following settings:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Check /etc/security/limits and /etc/security/olimits. Make sure fsize is -1&lt;/li&gt;&lt;li&gt;Issue an &quot;lsfs -q&quot; command, check if &quot;bf&quot; is enabled&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:small&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;pre&gt;Name            Nodename   Mount Pt               VFS   Size    Options    Auto Accounting&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:small&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;pre&gt;/dev/hd4        --         /                      jfs   786432  --         yes  no  &lt;/pre&gt;&lt;pre&gt;(lv size: 786432, fs size: 786432, frag size: 4096, nbpi: 2048, compress: no, bf: false, ag size: 8)&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/3924031514440835363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/3924031514440835363?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/3924031514440835363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/3924031514440835363'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/05/write-file-2g-on-aix.html' title='Write file &gt;2G on AIX'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-3380950297300868445</id><published>2007-05-10T09:52:00.000+08:00</published><updated>2007-05-10T09:54:15.099+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>Compute string&#39;s MD5 hash value</title><content type='html'>&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; s; &lt;span style=&quot;color: green;&quot;&gt;//User Input string&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; md5 = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;61a60170273e74a5be90355ffe8e86ad&quot;&lt;/span&gt;; &lt;span style=&quot;color: green;&quot;&gt;//MD5ed hash string&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;System.Text.&lt;span style=&quot;color: #2b91af;&quot;&gt;StringBuilder&lt;/span&gt; sb = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; System.Text.&lt;span style=&quot;color: #2b91af;&quot;&gt;StringBuilder&lt;/span&gt;();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;System.Security.Cryptography.&lt;span style=&quot;color: #2b91af;&quot;&gt;MD5CryptoServiceProvider&lt;/span&gt; hasher = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; System.Security.Cryptography.&lt;span style=&quot;color: #2b91af;&quot;&gt;MD5CryptoServiceProvider&lt;/span&gt;();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;[] hashed;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;hashed = hasher.ComputeHash(System.Text.&lt;span style=&quot;color: #2b91af;&quot;&gt;Encoding&lt;/span&gt;.Default.GetBytes(s));&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; hashed.Length; i++)&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;{&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(hashed[i].ToString(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;x2&quot;&lt;/span&gt;));&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;}&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (s == md5)&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;{&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;//...&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;}&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/3380950297300868445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/3380950297300868445?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/3380950297300868445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/3380950297300868445'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/05/compute-strings-md5-hash-value.html' title='Compute string&#39;s MD5 hash value'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-800209703322642887</id><published>2007-04-19T11:42:00.000+08:00</published><updated>2007-04-19T12:58:20.518+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Configuring log4net at Runtime</title><content type='html'>If you want to set up log4net in runtime instead of using XML configuration file, you can use the following code. After setting up options, do not forget to call ActivateOptions() method.&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; SetupLog()&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;{&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; log4net.Appender.&lt;span style=&quot;color: #2b91af;&quot;&gt;RollingFileAppender&lt;/span&gt; rLog = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; log4net.Appender.&lt;span style=&quot;color: #2b91af;&quot;&gt;RollingFileAppender&lt;/span&gt;();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; log4net.Layout.&lt;span style=&quot;color: #2b91af;&quot;&gt;PatternLayout&lt;/span&gt; pl = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; log4net.Layout.&lt;span style=&quot;color: #2b91af;&quot;&gt;PatternLayout&lt;/span&gt;();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pl.Header = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;=================\r\nStart of Program log\r\n&quot;&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pl.Footer = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;=================\r\nEnd of Program log\r\n&quot;&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pl.ConversionPattern = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%d [%t] %-5p %c - %m%n&quot;&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pl.ActivateOptions();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rLog.File = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Program.log&quot;&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rLog.RollingStyle = log4net.Appender.&lt;span style=&quot;color: #2b91af;&quot;&gt;RollingFileAppender&lt;/span&gt;.&lt;span style=&quot;color: #2b91af;&quot;&gt;RollingMode&lt;/span&gt;.Date;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rLog.LockingModel = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; log4net.Appender.&lt;span style=&quot;color: #2b91af;&quot;&gt;FileAppender&lt;/span&gt;.&lt;span style=&quot;color: #2b91af;&quot;&gt;MinimalLock&lt;/span&gt;();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rLog.AppendToFile = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rLog.Layout = pl;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rLog.DatePattern = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;yyyyMMdd&quot;&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rLog.StaticLogFileName = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rLog.ActivateOptions();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; log4net.Config.&lt;span style=&quot;color: #2b91af;&quot;&gt;BasicConfigurator&lt;/span&gt;.Configure(rLog);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;}&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/800209703322642887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/800209703322642887?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/800209703322642887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/800209703322642887'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/04/configuring-log4net-at-runtime.html' title='Configuring log4net at Runtime'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-6935029095534053392</id><published>2007-04-18T15:52:00.000+08:00</published><updated>2007-04-19T13:02:06.991+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="web"/><title type='text'>Loading UserControl at Runtime and Calling Function in UserControl</title><content type='html'>If you want to load ASP.NET User Control at runtime and calling methods in the UserControl class (such as filling data in the control), you can use the following code. Use reflection to get method in the UserControl then invoke it.&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;UserControl&lt;/span&gt; uc = &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;uc = (&lt;span style=&quot;color: #2b91af;&quot;&gt;UserControl&lt;/span&gt;)LoadControl(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;UserControl.ascx&quot;&lt;/span&gt;);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Type&lt;/span&gt; ucType = uc.GetType();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;MethodInfo&lt;/span&gt; mi = ucType.GetMethod(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;FillData&quot;&lt;/span&gt;);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; returnValue=(&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;)mi.Invoke(uc, &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;[] { arg1, arg2, arg3});&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/6935029095534053392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/6935029095534053392?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/6935029095534053392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/6935029095534053392'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/04/loading-usercontrol-at-runtime-and.html' title='Loading UserControl at Runtime and Calling Function in UserControl'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-7934861803624230905</id><published>2007-04-18T15:39:00.000+08:00</published><updated>2007-04-19T13:06:09.397+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="web"/><title type='text'>Using HttpWebRequest &amp; HttpWebResponse to POST Data</title><content type='html'>If you want to get a web page, use HttpWebRequest to make request, and use HttpWebResponse to get response. The following code demostrates how to make request by POST method, then get response from web server. You can get response content by manipulating stream st.&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;HttpWebRequest&lt;/span&gt; hwr;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;hwr = (&lt;span style=&quot;color: #2b91af;&quot;&gt;HttpWebRequest&lt;/span&gt;)&lt;span style=&quot;color: #2b91af;&quot;&gt;WebRequest&lt;/span&gt;.Create(url);&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;hwr.Method = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;POST&quot;&lt;/span&gt;;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; postdata = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;formpostdata=&quot;&lt;/span&gt; + System.Web.&lt;span style=&quot;color: #2b91af;&quot;&gt;HttpUtility&lt;/span&gt;.UrlEncode(dataToPost);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ASCIIEncoding&lt;/span&gt; enc = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ASCIIEncoding&lt;/span&gt;();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;[] bytel = enc.GetBytes(postdata);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;hwr.ContentType = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;application/x-www-form-urlencoded&quot;&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;hwr.ContentLength = bytel.Length;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;//write to request stream&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Stream&lt;/span&gt; newstream = hwr.GetRequestStream();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;newstream.Write(bytel, 0, bytel.Length);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;newstream.Close();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;hwr.Timeout = 10000;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;//get response&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;HttpWebResponse&lt;/span&gt; hwresp = (&lt;span style=&quot;color: #2b91af;&quot;&gt;HttpWebResponse&lt;/span&gt;)hwr.GetResponse();&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Stream&lt;/span&gt; st = hwresp.GetResponseStream();&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/7934861803624230905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/7934861803624230905?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/7934861803624230905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/7934861803624230905'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/04/using-httpwebrequest-httpwebresponse-to.html' title='Using HttpWebRequest &amp; HttpWebResponse to POST Data'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-2193640492798606964</id><published>2007-04-18T15:30:00.000+08:00</published><updated>2007-04-18T15:37:41.139+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="XML"/><title type='text'>Using .NET to Build a XML DOM</title><content type='html'>&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;XmlDocument&lt;/span&gt; xmldoc = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;XmlDocument&lt;/span&gt;();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;XmlDeclaration&lt;/span&gt; xmldec = xmldoc.CreateXmlDeclaration(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;1.0&quot;&lt;/span&gt;, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;yes&quot;&lt;/span&gt;);&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;xmldoc.InsertBefore(xmldec, xmldoc.DocumentElement);&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;XmlElement&lt;/span&gt; xmluser = xmldoc.CreateElement(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;userdata&quot;&lt;/span&gt;);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;xmldoc.DocumentElement.PrependChild(xmluser);&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;XmlElement&lt;/span&gt; name = xmldoc.CreateElement(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;name&quot;&lt;/span&gt;);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;name.AppendChild(xmldoc.CreateTextNode(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;abc123&quot;&lt;/span&gt;));&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;xmluser.AppendChild(name);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;XmlElement&lt;/span&gt; id = xmldoc.CreateElement(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;id&quot;&lt;/span&gt;);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;id.AppendChild(xmldoc.CreateTextNode(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;A100000000&quot;&lt;/span&gt;));&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;xmluser.AppendChild(id);&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/2193640492798606964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/2193640492798606964?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/2193640492798606964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/2193640492798606964'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/04/using-net-to-build-xml-dom.html' title='Using .NET to Build a XML DOM'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-6431429985224088069</id><published>2007-04-18T15:03:00.000+08:00</published><updated>2007-04-18T15:28:20.392+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Using .NET to Extract Zip Files</title><content type='html'>&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; ICSharpCode.SharpZipLib.Core;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; ICSharpCode.SharpZipLib.Zip;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ZipInputStream&lt;/span&gt; s = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ZipInputStream&lt;/span&gt;(&lt;span style=&quot;color: #2b91af;&quot;&gt;File&lt;/span&gt;.OpenRead(&lt;span style=&quot;color: #a31515;&quot;&gt;@&quot;c:\test.zip&quot;&lt;/span&gt;));&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ZipEntry&lt;/span&gt; e;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;[] buf = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;[4096];&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; BaseDir = &lt;span style=&quot;color: #a31515;&quot;&gt;@&quot;c:\test2\&quot;&lt;/span&gt;;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ZipNameTransform&lt;/span&gt; zt = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ZipNameTransform&lt;/span&gt;();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (!&lt;span style=&quot;color: #2b91af;&quot;&gt;Directory&lt;/span&gt;.Exists(BaseDir))&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Directory&lt;/span&gt;.CreateDirectory(BaseDir);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; ((e = s.GetNextEntry()) != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;{&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (e.IsFile)&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;FileStream&lt;/span&gt; fs = &lt;span style=&quot;color: #2b91af;&quot;&gt;File&lt;/span&gt;.Create(BaseDir + zt.TransformFile(e.Name));&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;StreamUtils&lt;/span&gt;.Copy(s, fs, buf);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Extracting &quot;&lt;/span&gt; + zt.TransformFile(e.Name));&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (e.IsDirectory)&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Directory&lt;/span&gt;.CreateDirectory(BaseDir + e.Name);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;}&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;s.Close();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;s.Dispose();&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/6431429985224088069/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/6431429985224088069?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/6431429985224088069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/6431429985224088069'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/04/using-icsharpcode.html' title='Using .NET to Extract Zip Files'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5419917401518431489.post-2730507408574489401</id><published>2007-04-18T14:46:00.000+08:00</published><updated>2007-04-18T15:29:44.731+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Using .NET to Compress Zip Files</title><content type='html'>Download &lt;a href=&quot;http://www.icsharpcode.net/OpenSource/SharpZipLib/&quot;&gt;http://www.icsharpcode.net/OpenSource/SharpZipLib/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; ICSharpCode.SharpZipLib.Core;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; ICSharpCode.SharpZipLib.Zip;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-family: 細明體; font-size: 9pt; color: black; background: white;&quot;&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ZipOutputStream&lt;/span&gt; s = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ZipOutputStream&lt;/span&gt;(&lt;span style=&quot;color: #2b91af;&quot;&gt;File&lt;/span&gt;.Create(&lt;span style=&quot;color: #a31515;&quot;&gt;@&quot;c:\test.zip&quot;&lt;/span&gt;));&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;[] buf = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;[4096];&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;s.SetLevel(5);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ZipEntry&lt;/span&gt; e;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; fn &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; filenames)&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;{&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ZipEntry&lt;/span&gt;(fn);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; s.PutNextEntry(e);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;FileStream&lt;/span&gt; fs = &lt;span style=&quot;color: #2b91af;&quot;&gt;File&lt;/span&gt;.OpenRead(fn);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;StreamUtils&lt;/span&gt;.Copy(fs, s, buf);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fs.Close();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fs.Dispose();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Adding &quot;&lt;/span&gt; + fn);&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;}&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;s.Close();&lt;/p&gt;&lt;p style=&quot;margin: 0px;&quot;&gt;s.Dispose();&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dhchentw.blogspot.com/feeds/2730507408574489401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5419917401518431489/2730507408574489401?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/2730507408574489401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5419917401518431489/posts/default/2730507408574489401'/><link rel='alternate' type='text/html' href='http://dhchentw.blogspot.com/2007/04/download-httpwww.html' title='Using .NET to Compress Zip Files'/><author><name>dhchen</name><uri>http://www.blogger.com/profile/14311222800948750646</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>