<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Geral</title>
        <link>http://geekswithblogs.net/sglima/category/9235.aspx</link>
        <description>Geral</description>
        <language>pt</language>
        <copyright>Sglima</copyright>
        <managingEditor>sglima@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>string.Format input string was not in a correct format</title>
            <link>http://geekswithblogs.net/sglima/archive/2011/12/19/string.format-input-string-was-not-in-a-correct-format.aspx</link>
            <description>
		&lt;span style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;If you have a "{" or "}" inside a string when using string.format you will get the error mentioned in the title.&lt;/span&gt;
		&lt;div style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;
				&lt;br /&gt;
		&lt;/div&gt;
		&lt;div style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;To fix this you must double the charater.&lt;/div&gt;
		&lt;div style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;
				&lt;br /&gt;
		&lt;/div&gt;
		&lt;div style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;Error Example: &lt;/div&gt;
		&lt;div style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;string teste = string.Format(" This is a {teste} {0} ", mystring);&lt;/div&gt;
		&lt;div style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;
				&lt;br /&gt;
		&lt;/div&gt;
		&lt;div style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;Correct Example:&lt;/div&gt;
		&lt;div style="font:/normal &amp;quot;Times New Roman&amp;quot;; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"&gt;string teste = string.Format(" This is a {{teste}} {0} ", mystring);v&lt;/div&gt;
 &lt;img src="http://geekswithblogs.net/sglima/aggbug/148084.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2011/12/19/string.format-input-string-was-not-in-a-correct-format.aspx</guid>
            <pubDate>Mon, 19 Dec 2011 15:46:18 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/148084.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2011/12/19/string.format-input-string-was-not-in-a-correct-format.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/148084.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to handle ""Maximum request length exceeded" exception</title>
            <link>http://geekswithblogs.net/sglima/archive/2011/09/20/how-to-handle-maximum-request-length-exceeded-exception.aspx</link>
            <description>&lt;p&gt;In global.asax:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre style="background: black; color: white; font-family: Consolas;"&gt;&lt;span style="color: rgb(147, 199, 99);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(147, 199, 99);"&gt;void&lt;/span&gt; Application_BeginRequest(&lt;span style="color: rgb(103, 140, 177);"&gt;Object&lt;/span&gt; sender, &lt;span style="color: rgb(103, 140, 177);"&gt;EventArgs&lt;/span&gt; e)
{
	&lt;span style="color: rgb(103, 140, 177);"&gt;HttpRuntimeSection&lt;/span&gt; runTime &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; (&lt;span style="color: rgb(103, 140, 177);"&gt;HttpRuntimeSection&lt;/span&gt;)&lt;span style="color: rgb(103, 140, 177);"&gt;WebConfigurationManager&lt;/span&gt;&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;GetSection(&lt;span style="color: rgb(236, 118, 0);"&gt;"system.web/httpRuntime"&lt;/span&gt;);
	&lt;span style="color: rgb(102, 116, 123);"&gt;//Approx 100 Kb(for page content) size has been deducted because the maxRequestLength proprty is the page size, not only the file upload size&lt;/span&gt;
	&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt; maxRequestLength &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; (runTime&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;MaxRequestLength &lt;span style="color: rgb(232, 226, 183);"&gt;-&lt;/span&gt; &lt;span style="color: rgb(255, 205, 34);"&gt;100&lt;/span&gt;) &lt;span style="color: rgb(232, 226, 183);"&gt;*&lt;/span&gt; &lt;span style="color: rgb(255, 205, 34);"&gt;1024&lt;/span&gt;;
 
	&lt;span style="color: rgb(102, 116, 123);"&gt;//This code is used to check the request length of the page and if the request length is greater than &lt;/span&gt;
	&lt;span style="color: rgb(102, 116, 123);"&gt;//MaxRequestLength then retrun to the same page with extra query string value action=exception&lt;/span&gt;

	&lt;span style="color: rgb(103, 140, 177);"&gt;HttpContext&lt;/span&gt; context &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; ((&lt;span style="color: rgb(103, 140, 177);"&gt;HttpApplication&lt;/span&gt;)sender)&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;Context;
	&lt;span style="color: rgb(147, 199, 99);"&gt;if&lt;/span&gt;(context&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;Request&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;ContentLength &lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;&lt;/span&gt; maxRequestLength)
	{
		&lt;span style="color: rgb(140, 140, 180);"&gt;IServiceProvider&lt;/span&gt; provider &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; (&lt;span style="color: rgb(140, 140, 180);"&gt;IServiceProvider&lt;/span&gt;)context;
		&lt;span style="color: rgb(103, 140, 177);"&gt;HttpWorkerRequest&lt;/span&gt; workerRequest &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; (&lt;span style="color: rgb(103, 140, 177);"&gt;HttpWorkerRequest&lt;/span&gt;)provider&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;GetService(&lt;span style="color: rgb(147, 199, 99);"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(103, 140, 177);"&gt;HttpWorkerRequest&lt;/span&gt;));
		&lt;span style="color: rgb(102, 116, 123);"&gt;// Check if body contains data&lt;/span&gt;
		&lt;span style="color: rgb(147, 199, 99);"&gt;if&lt;/span&gt;(workerRequest&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;HasEntityBody())
		{
			&lt;span style="color: rgb(102, 116, 123);"&gt;// get the total body length&lt;/span&gt;
			&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt; requestLength &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; workerRequest&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;GetTotalEntityBodyLength();
			&lt;span style="color: rgb(102, 116, 123);"&gt;// Get the initial bytes loaded&lt;/span&gt;
			&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt; initialBytes &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(255, 205, 34);"&gt;0&lt;/span&gt;;
			&lt;span style="color: rgb(147, 199, 99);"&gt;if&lt;/span&gt;(workerRequest&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;GetPreloadedEntityBody() &lt;span style="color: rgb(232, 226, 183);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(147, 199, 99);"&gt;null&lt;/span&gt;)
				initialBytes &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; workerRequest&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;GetPreloadedEntityBody()&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;Length;
			&lt;span style="color: rgb(147, 199, 99);"&gt;if&lt;/span&gt;(&lt;span style="color: rgb(232, 226, 183);"&gt;!&lt;/span&gt;workerRequest&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;IsEntireEntityBodyIsPreloaded())
			{
				&lt;span style="color: rgb(147, 199, 99);"&gt;byte&lt;/span&gt;[] buffer &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(147, 199, 99);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(147, 199, 99);"&gt;byte&lt;/span&gt;[&lt;span style="color: rgb(255, 205, 34);"&gt;512000&lt;/span&gt;];
				&lt;span style="color: rgb(102, 116, 123);"&gt;// Set the received bytes to initial bytes before start reading&lt;/span&gt;
				&lt;span style="color: rgb(147, 199, 99);"&gt;int&lt;/span&gt; receivedBytes &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; initialBytes;
				&lt;span style="color: rgb(147, 199, 99);"&gt;while&lt;/span&gt;(requestLength &lt;span style="color: rgb(232, 226, 183);"&gt;-&lt;/span&gt; receivedBytes &lt;span style="color: rgb(232, 226, 183);"&gt;&amp;gt;=&lt;/span&gt; initialBytes)
				{
					&lt;span style="color: rgb(102, 116, 123);"&gt;// Read another set of bytes&lt;/span&gt;
					initialBytes &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; workerRequest&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;ReadEntityBody(buffer, buffer&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;Length);
					&lt;span style="color: rgb(102, 116, 123);"&gt;// Update the received bytes&lt;/span&gt;
					receivedBytes &lt;span style="color: rgb(232, 226, 183);"&gt;+=&lt;/span&gt; initialBytes;
				}
				initialBytes &lt;span style="color: rgb(232, 226, 183);"&gt;=&lt;/span&gt; workerRequest&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;ReadEntityBody(buffer, requestLength &lt;span style="color: rgb(232, 226, 183);"&gt;-&lt;/span&gt; receivedBytes);
			}
		}
		&lt;span style="color: rgb(102, 116, 123);"&gt;// Redirect the user to the same page with querystring action=exception. &lt;/span&gt;
		context&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;Response&lt;span style="color: rgb(232, 226, 183);"&gt;.&lt;/span&gt;Redirect(&lt;span style="color: rgb(236, 118, 0);"&gt;"~/Erros/FicheiroGrande.aspx"&lt;/span&gt;);
	}
}&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a targuet="_blank" href="http://www.velocityreviews.com/forums/t97027-how-to-handle-maximum-request-length-exceeded-exception.html"&gt;Source&lt;/a&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/146957.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2011/09/20/how-to-handle-maximum-request-length-exceeded-exception.aspx</guid>
            <pubDate>Tue, 20 Sep 2011 11:36:54 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/146957.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2011/09/20/how-to-handle-maximum-request-length-exceeded-exception.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/146957.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to execute a javascript function every time an updatepanel executes an async postback</title>
            <link>http://geekswithblogs.net/sglima/archive/2011/09/20/how-to-execute-a-javascript-function-every-time-an-updatepanel.aspx</link>
            <description>&lt;p&gt;&amp;lt;script type="text/javascript" language="javascript"&amp;gt;&lt;/p&gt;
&lt;p&gt;        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(refresh);&lt;/p&gt;
&lt;p&gt;        function refresh()          {  		//Your code here;  	}&lt;/p&gt;
&lt;p&gt;&amp;lt;/script&amp;gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a targuet="_blank" href="http://zeemalik.wordpress.com/2007/11/27/how-to-call-client-side-javascript-function-after-an-updatepanel-asychronous-ajax-request-is-over/"&gt;Source&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/146956.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2011/09/20/how-to-execute-a-javascript-function-every-time-an-updatepanel.aspx</guid>
            <pubDate>Tue, 20 Sep 2011 09:57:32 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/146956.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2011/09/20/how-to-execute-a-javascript-function-every-time-an-updatepanel.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/146956.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to find locks in sql server 2000</title>
            <link>http://geekswithblogs.net/sglima/archive/2011/06/16/how-to-find-locks-in-sql-server-2000.aspx</link>
            <description>&lt;pre&gt;
/* Processes that are blocking others */
select * from 
sysprocesses
where spid in
(
select 
	blocked
from 
	syslocks l
	inner join sysprocesses p on p.spid=l.spid
where 
	p.dbid=5 -- Database ID
	and p.blocked&amp;lt;&amp;gt;0
)

/* Processes being blocked*/
select 
	p.*
from 
	syslocks l
	inner join sysprocesses p on p.spid=l.spid
where 
	p.dbid=5
	and p.blocked&amp;lt;&amp;gt;0
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/145884.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2011/06/16/how-to-find-locks-in-sql-server-2000.aspx</guid>
            <pubDate>Thu, 16 Jun 2011 16:03:56 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/145884.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2011/06/16/how-to-find-locks-in-sql-server-2000.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/145884.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to: Upload a file using FTP</title>
            <link>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-upload-a-file-using-ftp.aspx</link>
            <description>&lt;p&gt; FileInfo fileInf = new FileInfo("c:\myfile.txt");&lt;/p&gt;
&lt;p&gt;FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://myFTPSite/myfile.txt"));&lt;/p&gt;
&lt;p&gt;reqFTP.Credentials = new NetworkCredential("myUser","myPassword", "myFTPDomain");&lt;br /&gt;
 &lt;/p&gt;
&lt;p&gt;reqFTP.KeepAlive = false;&lt;br /&gt;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;&lt;br /&gt;
reqFTP.UseBinary = true;&lt;/p&gt;
&lt;p&gt;reqFTP.ContentLength = fileInf.Length;&lt;/p&gt;
&lt;p&gt;int buffLength = 2048;&lt;br /&gt;
byte[] buff = new byte[buffLength];&lt;br /&gt;
int contentLen;&lt;/p&gt;
&lt;p&gt;FileStream fs = fileInf.OpenRead();&lt;/p&gt;
&lt;p&gt;try&lt;br /&gt;
{&lt;br /&gt;
    Stream strm = reqFTP.GetRequestStream();&lt;br /&gt;
    contentLen = fs.Read(buff, 0, buffLength);&lt;br /&gt;
    while (contentLen != 0)&lt;br /&gt;
    {&lt;br /&gt;
        strm.Write(buff, 0, contentLen);&lt;br /&gt;
        contentLen = fs.Read(buff, 0, buffLength);&lt;br /&gt;
    }&lt;br /&gt;
    strm.Close();&lt;br /&gt;
    fs.Close();&lt;br /&gt;
}&lt;br /&gt;
catch (Exception ex)&lt;br /&gt;
{&lt;br /&gt;
    Console.WriteLine(ex.Message);&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Enjoy :)&lt;/p&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/142185.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-upload-a-file-using-ftp.aspx</guid>
            <pubDate>Thu, 07 Oct 2010 16:31:42 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/142185.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-upload-a-file-using-ftp.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/142185.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to: Download a file using FTP</title>
            <link>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-download-a-file-using-ftp.aspx</link>
            <description>&lt;p&gt;FileStream outputStream = new FileStream("c:\myfilefolder\file.txt");&lt;br /&gt;
FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://myFTPSite/file.txt"));&lt;/p&gt;
&lt;p&gt;reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;&lt;br /&gt;
reqFTP.UseBinary = true;&lt;br /&gt;
reqFTP.Credentials = new NetworkCredential("myUser","MyPassword","FTPDomain");&lt;/p&gt;
&lt;p&gt;FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();&lt;br /&gt;
Stream ftpStream = response.GetResponseStream();&lt;/p&gt;
&lt;p&gt;int bufferSize = 2048;&lt;br /&gt;
int readCount;&lt;br /&gt;
byte[] buffer = new byte[bufferSize];&lt;/p&gt;
&lt;p&gt;readCount = ftpStream.Read(buffer, 0, bufferSize);&lt;br /&gt;
while (readCount &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
    outputStream.Write(buffer, 0, readCount);&lt;br /&gt;
    readCount = ftpStream.Read(buffer, 0, bufferSize);&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;ftpStream.Close();&lt;br /&gt;
outputStream.Close();&lt;br /&gt;
response.Close();&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Enjoy :)&lt;/p&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/142183.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-download-a-file-using-ftp.aspx</guid>
            <pubDate>Thu, 07 Oct 2010 16:24:16 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/142183.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-download-a-file-using-ftp.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/142183.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to: List Files from an FTP Location</title>
            <link>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-list-files-from-an-ftp-location.aspx</link>
            <description>&lt;p&gt;FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://myFTPURL/"));&lt;br /&gt;
reqFTP.UseBinary = true;&lt;br /&gt;
reqFTP.Credentials = new NetworkCredential("myUser", "myPassword", "FTPDomain");&lt;/p&gt;
&lt;p&gt;reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;&lt;/p&gt;
&lt;p&gt;WebResponse response = reqFTP.GetResponse();&lt;br /&gt;
StreamReader reader = new StreamReader(response.GetResponseStream());&lt;/p&gt;
&lt;p&gt;string line = reader.ReadLine();&lt;br /&gt;
while (line != null)&lt;br /&gt;
{&lt;br /&gt;
    line = reader.ReadLine();&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;reader.Close();&lt;br /&gt;
response.Close();&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Enjoy :)&lt;/p&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/142182.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-list-files-from-an-ftp-location.aspx</guid>
            <pubDate>Thu, 07 Oct 2010 16:17:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/142182.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2010/10/07/how-to-list-files-from-an-ftp-location.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/142182.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to: Export A Class to XML</title>
            <link>http://geekswithblogs.net/sglima/archive/2010/08/17/how-to-export-a-class-to-xml.aspx</link>
            <description>&lt;p&gt;&lt;b&gt;The scenario: &lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Imagine someone asks you to create an XML file with some data structure.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;The approuch:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;There are several ways to achieve this, the fastest and less time comsuming is to create a class structure that represents the XML structure you need, fill in with the data and them serialize it to a string and save it to a file.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;The Implementation: &lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Lets say you need a single node, followed by an array of nodes.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Class Definition:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;public class MyNode&lt;br /&gt;
{&lt;/p&gt;
&lt;div style="padding-left: 20px"&gt;[XmlElementAttribute("code")]&lt;br /&gt;
public int code;&lt;br /&gt;
[XmlElementAttribute("description")]&lt;br /&gt;
public string description;&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;public class Item&lt;br /&gt;
{&lt;/p&gt;
&lt;div style="padding-left: 20px"&gt;[XmlAttribute("name")]&lt;br /&gt;
public string name;&lt;br /&gt;
[XmlAttribute("value")]&lt;br /&gt;
public string value;&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;[XmlRootAttribute("myClass", IsNullable = false, Namespace = "")]&lt;br /&gt;
public class MyClass&lt;br /&gt;
{&lt;/p&gt;
&lt;div style="padding-left: 20px"&gt;public MyClass()&lt;br /&gt;
{
&lt;div style="padding-left: 20px"&gt;myNode = new MyNode();&lt;/div&gt;
}
&lt;p&gt; &lt;/p&gt;
[XmlElementAttribute("myNode")]&lt;br /&gt;
public MyNode myNode;
&lt;p&gt; &lt;/p&gt;
[XmlArrayAttribute("myArray")]&lt;br /&gt;
public List&amp;lt;Item&amp;gt; myArray = new List&amp;lt;Item&amp;gt;();
&lt;p&gt; &lt;/p&gt;
public override string ToString()&lt;br /&gt;
{
&lt;div style="padding-left: 20px"&gt;try&lt;br /&gt;
{
&lt;div style="padding-left: 20px"&gt;string xmlString = null;&lt;br /&gt;
MemoryStream memoryStream = new MemoryStream();&lt;br /&gt;
XmlSerializer xs = new XmlSerializer(typeof(MyClass));&lt;br /&gt;
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);&lt;br /&gt;
xs.Serialize(xmlTextWriter, this);&lt;br /&gt;
memoryStream = (MemoryStream)xmlTextWriter.BaseStream;&lt;br /&gt;
xmlString = UTF8ByteArrayToString(memoryStream.ToArray());&lt;br /&gt;
return xmlString;&lt;/div&gt;
}&lt;br /&gt;
catch&lt;br /&gt;
{
&lt;div style="padding-left: 20px"&gt;return string.Empty;&lt;/div&gt;
}&lt;/div&gt;
}
&lt;p&gt; &lt;/p&gt;
private static string UTF8ByteArrayToString(byte[] characters)&lt;br /&gt;
{
&lt;div style="padding-left: 20px"&gt;UTF8Encoding encoding = new UTF8Encoding();&lt;br /&gt;
string constructedString = encoding.GetString(characters);&lt;br /&gt;
return (constructedString);&lt;/div&gt;
}
&lt;p&gt; &lt;/p&gt;
private static Byte[] StringToUTF8ByteArray(string pXmlString)&lt;br /&gt;
{
&lt;div style="padding-left: 20px"&gt;UTF8Encoding encoding = new UTF8Encoding();&lt;br /&gt;
byte[] byteArray = encoding.GetBytes(pXmlString);&lt;br /&gt;
return byteArray;&lt;/div&gt;
}
&lt;p&gt; &lt;/p&gt;
public static MyClass DeserializeObject(string xml)&lt;br /&gt;
{
&lt;div style="padding-left: 20px"&gt;XmlSerializer xs = new XmlSerializer(typeof(MyClass));&lt;br /&gt;
MemoryStream memoryStream = new MemoryStream(StringToUTF8ByteArray(xml));&lt;br /&gt;
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);&lt;br /&gt;
return (MyClass)xs.Deserialize(memoryStream);&lt;/div&gt;
}&lt;br /&gt;
 &lt;/div&gt;
&lt;p&gt;}&lt;br /&gt;
 &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Now, to use these classes:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;public static string myFunction()&lt;br /&gt;
{&lt;/p&gt;
&lt;div style="padding-left: 20px"&gt;MyClass fido = new MyClass();&lt;br /&gt;
fido.myNode.code = 1;&lt;br /&gt;
fido.myNode.description="sample text";&lt;br /&gt;
myArray.Add(new Item{name="name1", value="value1"});&lt;br /&gt;
myArray.Add(new Item{name="name2", value="value2"});&lt;br /&gt;
return fido.ToString();&lt;/div&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Executing this you will get an string as such:&lt;/p&gt;
&lt;p&gt;﻿&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;
&amp;lt;myClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&amp;gt;&lt;/p&gt;
&lt;div style="padding-left: 20px"&gt;&amp;lt;myNode&amp;gt;
&lt;div style="padding-left: 20px"&gt;&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;description&amp;gt;sample text&amp;lt;/description&amp;gt;&lt;/div&gt;
&amp;lt;/myNode&amp;gt;&lt;br /&gt;
&amp;lt;myArray&amp;gt;
&lt;div style="padding-left: 20px"&gt;&amp;lt;Item name="name1" value="value1" /&amp;gt;&lt;br /&gt;
&amp;lt;Item name="name2" value="value2" /&amp;gt;&lt;/div&gt;
&amp;lt;/myArray&amp;gt;&lt;/div&gt;
&lt;p&gt;&amp;lt;/myClass&amp;gt;&lt;/p&gt;
&lt;p&gt;Using the string returned from "fido.ToString()" in the method DeserializeObject will get you the original values for the object.&lt;/p&gt;
&lt;p&gt;Hope this can be helpfull,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Enjoy :)&lt;/p&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/141352.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2010/08/17/how-to-export-a-class-to-xml.aspx</guid>
            <pubDate>Tue, 17 Aug 2010 15:54:40 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/141352.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2010/08/17/how-to-export-a-class-to-xml.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/141352.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Linq error: MSDTC on server 'servername' is unavailable</title>
            <link>http://geekswithblogs.net/sglima/archive/2010/08/11/linq-error-msdtc-on-server-servername-is-unavailable.aspx</link>
            <description>&lt;p&gt;Occasionally an application that I am working on throws the above error... &lt;/p&gt;
&lt;p&gt;After trying to fix my code for a bit, and not finding the problem I googled a bit and discovered that this error is caused by a windows service that must be running.&lt;/p&gt;
&lt;p&gt;So, if you ever encounter this error, you must turn on the 'Distributed Transaction Coordinator' in order to solve it.&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;
Original source: &lt;a href="http://geekswithblogs.net/narent/archive/2006/10/09/93544.aspx"&gt;http://geekswithblogs.net/narent/archive/2006/10/09/93544.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/141277.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2010/08/11/linq-error-msdtc-on-server-servername-is-unavailable.aspx</guid>
            <pubDate>Wed, 11 Aug 2010 11:39:50 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/141277.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2010/08/11/linq-error-msdtc-on-server-servername-is-unavailable.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/141277.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to: Update a table from a select</title>
            <link>http://geekswithblogs.net/sglima/archive/2010/07/09/how-to-update-a-table-from-a-select.aspx</link>
            <description>&lt;div&gt;&lt;span style="color: blue; font-size: 10pt"&gt;update&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; n&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color: blue; font-size: 10pt"&gt;set&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size: 10pt"&gt;&lt;span style="color: gray"&gt;    n.&lt;/span&gt;fieldToUpdate&lt;span style="color: gray"&gt;=o&lt;/span&gt;&lt;span style="color: gray"&gt;.&lt;/span&gt;fieldToUpdateFrom &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color: blue; font-size: 10pt"&gt;from&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size: 10pt"&gt;   originaltable o &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color: gray; font-size: 10pt"&gt;   inner&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; &lt;span style="color: gray"&gt;join&lt;/span&gt; toTable n &lt;span style="color: blue"&gt;on&lt;/span&gt; n&lt;span style="color: gray"&gt;.&lt;/span&gt;id&lt;span style="color: gray"&gt;=&lt;/span&gt; o&lt;span style="color: gray"&gt;.&lt;/span&gt;id&lt;/span&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt; &lt;img src="http://geekswithblogs.net/sglima/aggbug/140848.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sglima</dc:creator>
            <guid>http://geekswithblogs.net/sglima/archive/2010/07/09/how-to-update-a-table-from-a-select.aspx</guid>
            <pubDate>Fri, 09 Jul 2010 13:00:36 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/sglima/comments/140848.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/sglima/archive/2010/07/09/how-to-update-a-table-from-a-select.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/sglima/comments/commentRss/140848.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
