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

<channel>
	<title>WiseCodes &#187; C#.Net</title>
	<atom:link href="http://www.wisecodes.com/tag/cnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wisecodes.com</link>
	<description>Bringing You The Power of Code !!</description>
	<lastBuildDate>Wed, 01 Sep 2010 19:33:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Linq to NHibernate, Version 1.0</title>
		<link>http://www.wisecodes.com/2009/09/linq-to-nhibernate-version-1-0/</link>
		<comments>http://www.wisecodes.com/2009/09/linq-to-nhibernate-version-1-0/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 19:55:11 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[LINQ]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=856</guid>
		<description><![CDATA[A few weeks ago, Oren Eini (Ayende Raihan or, as is often referred to) communicated the release of version 1.0 of the Linq provider for NHibernate, a feature highly demanded by users since the advent of integrated query language. NET. Although it will be included as part of NHibernate product in future versions, have decided [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, <strong><a href="http://ayende.com/blog" target="_blank">Oren Eini</a></strong> (Ayende Raihan or, as is often referred to) <strong><a href="http://ayende.com/Blog/archive/2009/07/26/nhibernate-linq-1.0-released.aspx" target="_blank">communicated</a></strong> the release of version 1.0 of the Linq provider for NHibernate, a feature highly demanded by users since the advent of integrated query language. NET.</p>
<p>Although it will be included as part of NHibernate product in future versions, have decided to release the current release of the supplier as separate package so you can start to be used from now. It is being tested in many applications in production for several years, and apparently the performance is just right.</p>
<p>And how can help the supplier, if you&#8217;re user of NHibernate? The following example from <strong><a href="http://www.caffeinatedcoder.com/linq-to-nhibernate/" target="_blank">Caffeinated Coder</a></strong> demonstrates how to query database can be simplified and made more readable using Linq and also benefit from strong typing, intellisense and compile-time checks:</p>
<p><strong>Using NHibernate API:</strong></p>
<pre class="brush: csharp;">
public IList&lt;Call&gt; GetCallsByDate(DateTime beginDate, int interpreterId)
{
    ICriteria criteria = Session.CreateCriteria(typeof(Call))
        .CreateAlias(&quot;Customer&quot;, &quot;Customer&quot;)
        .Add(Restrictions.Gt(&quot;StartTime&quot;, beginDate))
        .Add(
            Restrictions.Or(
                Restrictions.Lt(&quot;EndTime&quot;, DateTime.Now), Restrictions.IsNull(&quot;EndTime&quot;))
            )
        .Add(Restrictions.Eq(&quot;Interpreter.Id&quot;, interpreterId))
        .AddOrder(Order.Desc(&quot;StartTime&quot;))
        .AddOrder(Order.Desc(&quot;Customer.Name&quot;));
        return criteria.List&lt;Call&gt;() as List&lt;Call&gt;;
}
</pre>
<p><strong>Using Linq:</strong></p>
<pre class="brush: csharp;">
public IList&lt;Call&gt; GetCallsByDateWithLinq(DateTime beginDate, int interpreterId)
{
    var query = from call in Session.Linq&lt;Call&gt;()
        where call.StartTime &gt; beginDate
            &amp;&amp; (call.EndTime == null || call.EndTime &lt; DateTime.Now )
            &amp;&amp; call.Interpreter.Id == interpreterId
        orderby call.StartTime descending, call.Customer.Name
        select call;

    return query.ToList();
}
</pre>
<p>You can download both binaries and source code from the <strong><a href="http://sourceforge.net/projects/nhibernate/" target="_blank">SourceForge project page.</a></strong></p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/09/linq-to-nhibernate-version-1-0/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/09/linq-to-nhibernate-version-1-0/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/09/linq-to-nhibernate-version-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code in C# to create a backup of a database in SQL server and restore it</title>
		<link>http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/</link>
		<comments>http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 20:04:47 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[BackUp]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Restore]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=787</guid>
		<description><![CDATA[Here they left a code in C # very useful when making your applications with databases in SQL server can support the database and restore it. Support code for a button: private void btnBackUp_Click(object sender, EventArgs e) { bool bBackUpStatus = true; Cursor.Current = Cursors.WaitCursor; if (Directory.Exists(@&#34;c:\SQLBackup&#34;)) { if (File.Exists(@&#34;c:\SQLBackup\wcBackUp1.bak&#34;)) { if (MessageBox.Show(@&#34;Do you want [...]]]></description>
			<content:encoded><![CDATA[<p>Here they left a code in C # very useful when making your applications with databases in SQL server can support the database and restore it.</p>
<p>Support code for a button:</p>
<pre class="brush: csharp;">
private void btnBackUp_Click(object sender, EventArgs e)
{
    bool bBackUpStatus = true;

    Cursor.Current = Cursors.WaitCursor; 

     if (Directory.Exists(@&quot;c:\SQLBackup&quot;))
        {
            if (File.Exists(@&quot;c:\SQLBackup\wcBackUp1.bak&quot;))
            {
                if (MessageBox.Show(@&quot;Do you want to replace it?&quot;, &quot;Back&quot;, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    File.Delete(@&quot;c:\SQLBackup\wcBackUp1.bak&quot;);
                }
                else
                    bBackUpStatus = false;
            }
        }
        else
            Directory.CreateDirectory(@&quot;c:\SQLBackup&quot;);

        if (bFileStatus)
        {
            //Connect to DB
            SqlConnection connect;
            string con = &quot;Data Source = localhost; Initial Catalog=dbWiseCodes ;Integrated Security = True;&quot;;
            connect = new SqlConnection(con);
            connect.Open();
            //----------------------------------------------------------------------------------------------------

            //Execute SQL---------------
            SqlCommand command;
            command = new SqlCommand(@&quot;backup database dbWiseCodes to disk ='c:\SQLBackup\wcBackUp1.bak' with init,stats=10&quot;, connect);
            command.ExecuteNonQuery();
            //-------------------------------------------------------------------------------------------------------------------------------

            connect.Close();

            MessageBox.Show(&quot;The support of the database was successfully performed&quot;, &quot;Back&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
}
</pre>
<p>Code for a button to restore:</p>
<pre class="brush: csharp;">

private void btnRestore_Click(object sender, EventArgs e)
{

    Cursor.Current = Cursors.WaitCursor;

    try
    {
        if (File.Exists(@&quot;c:\SQLBackup\wcBackUp1.bak&quot;))
        {
            if (MessageBox.Show(&quot;Are you sure you restore?&quot;, &quot;Back&quot;, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //Connect SQL-----------
                SqlConnection connect;
                string con = &quot;Data Source = localhost; Initial Catalog=master ;Integrated Security = True;&quot;;
                connect = new SqlConnection(con);
                connect.Open();
                //-----------------------------------------------------------------------------------------

                //Excute SQL----------------
                SqlCommand command;
          command = new SqlCommand(&quot;use master&quot;, connect);
            command.ExecuteNonQuery();
                command = new SqlCommand(@&quot;restore database dbWiseCodes01 from disk = 'c:\SQLBackup\wcBackUp1.bak'&quot;, connect);
                command.ExecuteNonQuery();
                //--------------------------------------------------------------------------------------------------------
                connect.Close();

                MessageBox.Show(&quot;Has been restored database&quot;, &quot;Restoration&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        else
            MessageBox.Show(@&quot;Do not make any endorsement above (or is not in the correct path)&quot;, &quot;Restoration&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information);

    }
    catch (Exception exp)
    {
        MessageBox.Show(exp.Message);
    }

}
</pre>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>.NET: Checking whether an Internet connection is available</title>
		<link>http://www.wisecodes.com/2009/05/net-checking-whether-an-internet-connection-is-available/</link>
		<comments>http://www.wisecodes.com/2009/05/net-checking-whether-an-internet-connection-is-available/#comments</comments>
		<pubDate>Wed, 20 May 2009 13:48:43 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=492</guid>
		<description><![CDATA[The method using ping checks whether there is an internet connection or not? In C#.NET The following namespace is required: using System.Net.NetworkInformation; /// &#60;Summary&#62; /// Checks whether an Internet connection is available. /// &#60;/Summary&#62; /// &#60;Returns&#62; /// True / false /// &#60;/Returns&#62; /// Site: WiseCodes.Com public static bool wcCheckInternetConnectionStatus() { Ping pingSender = new Ping(); [...]]]></description>
			<content:encoded><![CDATA[<p>The method using ping checks whether there is an internet connection or not?</p>
<p>In C#.NET</p>
<p>The following namespace is required:</p>
<pre class="brush: vb;">
using System.Net.NetworkInformation;
</pre>
<pre class="brush: vb;">
/// &lt;Summary&gt;
/// Checks whether an Internet connection is available.
/// &lt;/Summary&gt;
/// &lt;Returns&gt;
/// True / false
/// &lt;/Returns&gt;
/// Site: WiseCodes.Com

public static bool wcCheckInternetConnectionStatus()
{
 Ping pingSender = new Ping();

 try
 {
PingReply pReply = pingSender.Send(&quot;www.microsoft.com&quot;, 100);

 return pReply.Status == IPStatus.Success;
 }
 catch
 {
 return false;
 }
}
</pre>
<p>Link: <a href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.aspx " target="_blank">System.Net.NetworkInformation Namespace (Via MSDN)</a></p>
<p>Happy Programming!! <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/05/net-checking-whether-an-internet-connection-is-available/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/05/net-checking-whether-an-internet-connection-is-available/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/05/net-checking-whether-an-internet-connection-is-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET: Check links (http, https, ftp, news etc &#8230;)</title>
		<link>http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/</link>
		<comments>http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/#comments</comments>
		<pubDate>Wed, 13 May 2009 18:42:58 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=467</guid>
		<description><![CDATA[In this article we show how we can know what kind of address is an address. We will use the URI class, which does not allow URLs to work. The class belongs to the URI name space System. The URI class has property &#8220;Scheme&#8221; that indicates the type of URI scheme today. The schemes that [...]]]></description>
			<content:encoded><![CDATA[<p>In this article we show how we can know what kind of address is an address. We will use the URI class, which does not allow URLs to work. The class belongs to the URI name space System.</p>
<p>The URI class has property &#8220;Scheme&#8221; that indicates the type of URI scheme today. The schemes that detects the URI class are:</p>
<p>* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemefile.aspx" target="_blank">UriSchemeFile</a>: tells us that points the direction in which our class is a file URI.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemeftp.aspx" target="_blank">UriSchemeFtp</a>: the scheme is FTP (File Transfer Protocol)<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemegopher.aspx" target="_blank">UriSchemeGopher</a>: specifies that we can access through URI using the Gopher protocol.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemehttp.aspx" target="_blank">UriSchemeHttp</a>: access is a URI using the HTTP protocol.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemehttps.aspx" target="_blank">UriSchemeHttps</a>: the address is https, http secure.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischememailto.aspx" target="_blank">UriSchemeMailto</a>: tells us that the address is an e-mail, which can be accessed via SMTP.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemenetpipe.aspx" target="_blank">UriSchemeNetPipe</a>: tells us that the identifier URI is NetPipe.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemenettcp.aspx" target="_blank">UriSchemeNetTcp</a>: can access through URI using the protocol NetTCP.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemenews.aspx" target="_blank">UriSchemeNews</a>: URI is the address of a newsgroup or News.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemenntp.aspx" target="_blank">UriSchemeNntp</a>: a newsgroup is accessed via NNTP.</p>
<p>The fields above are just reading.</p>
<p>In the following example, create a constant that contains the address from which we obtain information and identify which type of management is our constant.</p>
<p><strong>In Visual Basic:</strong></p>
<pre class="brush: vb;">
Const strURL As String = “http://www.wisecodes.com”
Dim strDir As New Uri(strURL)
Select Case strDir.Scheme
Case Uri.UriSchemeFile
'Code for when the address is a file
Case Uri.UriSchemeFtp
'Code for when the address is ftp
Case Uri.UriSchemeGopher
'Code for when the address is a file Gopher
Case Uri.UriSchemeHttp
'Code for when the address is http
Case Uri.UriSchemeHttps
'Code for when the address is https
Case Uri.UriSchemeMailto
'Code for when the address is an e-mail
Case Uri.UriSchemeNetPipe
'Code for when the address is NetPipe
Case Uri.UriSchemeNetTcp
'Code for when the address is NetTcp
Case Uri.UriSchemeNews
'Code for when the address is a newsgroup
Case Uri.UriSchemeNntp
'Code for when the address is a newsgroup
'accessible via NNTP.
End Select
</pre>
<p><strong>In C Sharp</strong></p>
<pre class="brush: csharp;">
const string strURL = “http://www.wisecodes.com”
Uri strDir = new Uri (strURL);
switch (strDir.Scheme)
{
case Uri.SchemeFile:
//Code for when the address is a file
case Uri.UriSchemeFtp:
//Code for when the address is ftp
case Uri.UriSchemeGopher:
//Code for when the address is a file Gopher
case Uri.UriSchemeHttp:
//Code for when the address is http
case Uri.UriSchemeHttps:
//Code for when the address is https
case Uri.UriSchemeMailto:
//Code for when the address is an e-mail
case Uri.UriSchemeNetPipe:
//Code for when the address is NetPipe
case Uri.UriSchemeNetTcp:
//Code for when the address is NetTcp
case Uri.UriSchemeNews:
//Code for when the address is a newsgroup
caseUri.UriSchemeNntp:
//Code for when the address is a newsgroup
//accessible via NNTP.
}
</pre>
<p>Link: Via <a href="http://msdn.microsoft.com/en-us/library/system.uri_fields.aspx" target="_blank">Microsoft</a><br />
Happy Programming!! <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Desktop Refreshing in .NET</title>
		<link>http://www.wisecodes.com/2009/04/desktop-refreshing-in-net/</link>
		<comments>http://www.wisecodes.com/2009/04/desktop-refreshing-in-net/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 20:11:12 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Refresh]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=382</guid>
		<description><![CDATA[With this method, you can rebuild the desktop (for example, if the icon has re-positioned via code) public static void wc_RefreshDesktop() { SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero); } Happy Programming!! Share on Facebook]]></description>
			<content:encoded><![CDATA[<p>With this method, you can rebuild the desktop (for example, if the icon has re-positioned via code)</p>
<pre class="brush: csharp;">
public static void wc_RefreshDesktop()
{
 SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
}
</pre>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/desktop-refreshing-in-net/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/desktop-refreshing-in-net/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/desktop-refreshing-in-net/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Reading source code of a WebPage</title>
		<link>http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/</link>
		<comments>http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 19:36:10 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=376</guid>
		<description><![CDATA[This method, get the HTML source code of any WebPage C#.NET using System.Net; WebClient webClient = new WebClient(); string strHTMLSourceCode = webClient.DownloadString(&#34;http://www.microsoft.com&#34;); VB.NET Imports System.Net Dim webClient As WebClient = New WebClient() Dim strHTMLSourceCode As String = webClient.DownloadString(&#34;http://www.microsoft.com&#34;) Read More about webClient.DownloadString(string)&#8230; Happy Programming!! Share on Facebook]]></description>
			<content:encoded><![CDATA[<p>This method, get the HTML source code of any WebPage</p>
<p><span style="text-decoration: underline;"><strong>C#.NET</strong></span></p>
<pre class="brush: csharp;">
using System.Net;

WebClient webClient = new WebClient();
string strHTMLSourceCode = webClient.DownloadString(&quot;http://www.microsoft.com&quot;);
</pre>
<p><span style="text-decoration: underline;"><strong>VB.NET</strong></span></p>
<pre class="brush: vb;">
Imports System.Net

Dim webClient As WebClient = New WebClient()
Dim strHTMLSourceCode As String = webClient.DownloadString(&quot;http://www.microsoft.com&quot;)
</pre>
<p>Read More about <a href="http://msdn.microsoft.com/en-us/library/fhd1f0sw(VS.85).aspx" target="_blank">webClient.DownloadString(string)&#8230;</a></p>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net Gridview to CSV, Excel</title>
		<link>http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/</link>
		<comments>http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 19:00:57 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=372</guid>
		<description><![CDATA[This method, export to Excel file from Gridview VB.NET Sub wc_gvGridviewToExcel(ByVal gvGridview As Gridview, ByVal strExcelFilePath As String) 'Columns Dim intColumnsCount As Integer = gvGridview.Columns.Count - 1 'Header Dim strHeaderNames As String = Nothing For i = 0 To intColumnsCount strHeaderNames += gvGridview.Columns(i).HeaderText &#38; &#34;;&#34; Next WriteToExcel(strHeaderNames, strExcelFilePath) 'Each Row Dim strRowText As String = [...]]]></description>
			<content:encoded><![CDATA[<p>This method, export to Excel file from Gridview</p>
<p><span style="text-decoration: underline;"><strong>VB.NET</strong></span></p>
<pre class="brush: vb;">

Sub wc_gvGridviewToExcel(ByVal gvGridview As Gridview, ByVal strExcelFilePath As String)

'Columns

Dim intColumnsCount As Integer = gvGridview.Columns.Count - 1

'Header

Dim strHeaderNames As String = Nothing

For i = 0 To intColumnsCount

strHeaderNames += gvGridview.Columns(i).HeaderText &amp; &quot;;&quot;

Next

WriteToExcel(strHeaderNames, strExcelFilePath)

'Each Row

Dim strRowText As String = Nothing

For Each grdRow As gvGridviewRow In gvGridview.Rows

For i = 0 To intColumnsCount

strRowText += grdRow.Cells(i).Text &amp; &quot;;&quot;

Next

WriteToExcel(strRowText, strExcelFilePath)

strRowText = Nothing

Next

End Sub

Sub WriteToExcel(ByVal strText As String, ByVal strExcelFileName As String)

Dim myFileWriter As New System.IO.StreamWriter(strExcelFileName, True)

myFileWriter.WriteLine(strText)

myFileWriter.Close()

End Sub
</pre>
<p><span style="text-decoration: underline;"><strong>C#.NET</strong></span></p>
<pre class="brush: csharp;">
public void wc_gvGridviewToExcel(Gridview gvGridview, string strExcelFilePath)
{

 //Columns

 int intColumnsCount = gvGridview.Columns.Count - 1;

 //Header

 string strHeaderNames = null;

 for (i = 0; i &lt;= intColumnsCount; i++) {

 strHeaderNames += gvGridview.Columns(i).HeaderText + &quot;;&quot;;
 }

 WriteToExcel(strHeaderNames, strExcelFilePath);

 //Each Row

 string strRowText = null;

 foreach (gvGridviewRow grdRow in gvGridview.Rows) {

 for (i = 0; i &lt;= intColumnsCount; i++) {

 strRowText += grdRow.Cells(i).Text + &quot;;&quot;;
 }

 WriteToExcel(strRowText, strExcelFilePath);

 strRowText = null;

 }
}

public void WriteToExcel(string strText, string strExcelFileName)
{

 System.IO.StreamWriter myFileWriter = new System.IO.StreamWriter(strExcelFileName, true);

 myFileWriter.WriteLine(strText);

 myFileWriter.Close();
}
</pre>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compare Files</title>
		<link>http://www.wisecodes.com/2009/04/compare-files/</link>
		<comments>http://www.wisecodes.com/2009/04/compare-files/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 16:49:40 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=369</guid>
		<description><![CDATA[This method Compares 2 files and returns true or false. C#.NET private bool wc_CompareFiles(string FilePath1, string FilePath2) { FileInfo FI1 = new FileInfo(FilePath1); FileInfo FI2 = new FileInfo(FilePath2); if (FI1.Length != FI2.Length) return false; byte[] Filebytes1 = File.ReadAllBytes(FilePath1); byte[] Filebytes2 = File.ReadAllBytes(FilePath2); if (Filebytes1.Length != Filebytes2.Length) return false; for (int i = 0; i &#38;lt;= [...]]]></description>
			<content:encoded><![CDATA[<p>This method Compares 2 files and returns true or false.</p>
<p><span style="text-decoration: underline;"><strong>C#.NET</strong></span></p>
<pre class="brush: csharp;">
private bool wc_CompareFiles(string FilePath1, string FilePath2)
{
FileInfo FI1 = new FileInfo(FilePath1);
FileInfo FI2 = new FileInfo(FilePath2);

if (FI1.Length != FI2.Length)
return false;

byte[] Filebytes1 = File.ReadAllBytes(FilePath1);
byte[] Filebytes2 = File.ReadAllBytes(FilePath2);

if (Filebytes1.Length != Filebytes2.Length)
return false;

for (int i = 0; i &amp;lt;= Filebytes2.Length - 1; i++)
{
if (Filebytes1[i] != Filebytes2[i])
return false;
}
return true;
}
</pre>
<p><span style="text-decoration: underline;"><strong>VB.NET</strong></span></p>
<pre class="brush: vb;">

Private Function wc_CompareFiles(ByVal FilePath1 As String, ByVal FilePath2 As String) As Boolean
 Dim FI1 As New FileInfo(FilePath1)
 Dim FI2 As New FileInfo(FilePath2)

 If FI1.Length &lt;&gt; FI2.Length Then
 Return False
 End If

 Dim Filebytes1 As Byte() = File.ReadAllBytes(FilePath1)
 Dim Filebytes2 As Byte() = File.ReadAllBytes(FilePath2)

 If Filebytes1.Length &lt;&gt; Filebytes2.Length Then
 Return False
 End If

 For i As Integer = 0 To Filebytes2.Length - 1
 If Filebytes1(i) &lt;&gt; Filebytes2(i) Then
 Return False
 End If
 Next
 Return True
End Function
</pre>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/compare-files/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/compare-files/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/compare-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LinqPad</title>
		<link>http://www.wisecodes.com/2009/04/linqpad/</link>
		<comments>http://www.wisecodes.com/2009/04/linqpad/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 02:51:13 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[LINQ]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=356</guid>
		<description><![CDATA[I just learned of the existence of a very interesting tool called LinqPad, which allows query data using LINQ with. Net Framework 3.5. Click on the image to view large. Allows queries like: a) LINQ to SQL b) LINQ to Objects c) LINQ to XML After doing some tests I can say that is an [...]]]></description>
			<content:encoded><![CDATA[<p>I just learned of the existence of a very interesting tool called <a href="http://www.linqpad.net/" target="_blank">LinqPad</a>, which allows query data using LINQ with. Net Framework 3.5.</p>
<p><em>Click on the image to view large.</em><br />
<a href="http://www.linqpad.net/linqpadscreen.png" target="_blank"><img class="alignnone" src="http://www.linqpad.net/linqpadscreen.png" alt="" width="424" height="354" /></a></p>
<p>Allows queries like:</p>
<p>a) LINQ to SQL<br />
b) LINQ to Objects<br />
c) LINQ to XML</p>
<p>After doing some tests I can say that is an excellent tool, very comprehensive and allows flexibility to experience the power of LINQ and more of this interesting framework, which aims to be the big bet. NET for data access.</p>
<p><a href="http://www.linqpad.net/" target="_blank">Read More about LinqPad</a>&#8230;</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/linqpad/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/linqpad/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/linqpad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FTP file upload in .NET 2.0</title>
		<link>http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/</link>
		<comments>http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 20:34:20 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[.NET 3.0]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[.NET 2.0]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=317</guid>
		<description><![CDATA[It is clear that the FileUpload components, which can be found on the Standard toolbar of Visual Studio 2005 allows uploading files to the remote site, but does not cover all the expectations desired or at least not mine. So it is interesting to know how we can attack a specific server and an FTP [...]]]></description>
			<content:encoded><![CDATA[<p>It is clear that the FileUpload components, which can be found on the Standard toolbar of Visual Studio 2005 allows uploading files to the remote site, but does not cover all the expectations desired or at least not mine.<br />
So it is interesting to know how we can attack a specific server and an FTP to copy the desired file to the remote location to stay.</p>
<p>To do this:</p>
<p><strong>Step 1: </strong>In general declarations establish that the class will use.</p>
<p><strong>C#</strong></p>
<pre class="brush: csharp;">
using System.Net;
</pre>
<p><strong>VB.NET</strong></p>
<pre class="brush: vb;">
Imports System.Net
</pre>
<p><strong>Step 2:</strong> Create a button in the Click event and write the following code in C# or VB.NET:</p>
<p><strong>C#</strong></p>
<pre class="brush: csharp;">
private static void wc_UploadFTP(string ftpServerPath, string filename, string username, string password)
 {
WebClient ClientFtp = new WebClient() ;
ClientFtp.Credentials = new NetworkCredential(username, password);
ClientFtp.UploadFile(ftpServerPath + &quot;/&quot; + new FileInfo(filename).Name, &quot;STOR&quot;, filename);
}
</pre>
<p><strong>VB.NET</strong></p>
<pre class="brush: vb;">

Private Shared Sub wc_UploadFTP(ByVal ftpServerPath As String, ByVal filename As String, ByVal username As String, ByVal password As String)
 Dim ClientFtp As New WebClient()
 ClientFtp.Credentials = New NetworkCredential(username, password)
 ClientFtp.UploadFile((ftpServerPath &amp; &quot;/&quot;) + New FileInfo(filename).Name, &quot;STOR&quot;, filename)
End Sub
</pre>
</pre>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

