<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:snippet="http://codexchange.org/schemas/snippet/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title>CodeXchange: Top Rated Snippets</title>
    <link>http://www.codexchange.org</link>
    <description>Summary of the top rated snippets published on CodeXchange</description>
    <language>en-us</language>
    <copyright>Copyright © CodeXchange, 2004-2006</copyright>
    <generator>CodeXchange RSS Feed Generator v1.0</generator>
    <webMaster>webmaster@codexchange.org</webMaster>
    <lastBuildDate>Wed, 22 May 2013 09:37:39 GMT</lastBuildDate>
    <ttl>20</ttl>
    <dc:language>en-us</dc:language>
    <dc:rights>Copyright © CodeXchange, 2004-2006</dc:rights>
    <dc:date>5/22/2013 9:37:39 AM</dc:date>
    <dc:publisher />
    <dc:creator>CodeXchange RSS Feed Generator v1.0</dc:creator>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=593322b8-5915-469d-a1c1-0ac972c5a97c</guid>
      <title>Get Short and Long Path Names</title>
      <link>/PreviewSnippet.aspx?SnippetID=593322b8-5915-469d-a1c1-0ac972c5a97c</link>
      <description>Get Short and Long Path Names [VB.NET]</description>
      <author>J B</author>
      <pubDate>Thu, 26 Jan 2006 09:22:01 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=593322b8-5915-469d-a1c1-0ac972c5a97c#comments</comments>
      <category>bb47ac87-7cde-45ac-aa6e-e677d46fc216</category>
      <dc:title>Get Short and Long Path Names</dc:title>
      <dc:date>1/26/2006 9:22:01 AM</dc:date>
      <dc:creator>J B</dc:creator>
      <content:encoded><![CDATA[<pre>    Private Declare Auto Function GetShortPathName Lib "kernel32.dll" (ByVal strLongPath As String, ByVal objStringBuilder As System.Text.StringBuilder, ByVal intBufferSize As Integer) As Integer
    Private Declare Auto Function GetLongPathName Lib "kernel32.dll" (ByVal strShortPath As String, ByVal objStringBuilder As System.Text.StringBuilder, ByVal intBufferSize As Integer) As Integer

    Public Enum DirectoryPathLength
        WindowsXP = 256
    End Enum

    Public Function GetShortPathName(ByVal strPath As String, Optional ByVal enumDirectoryPathLength As DirectoryPathLength = DirectoryPathLength.WindowsXP) As String
        Dim strStringBuilder As New System.Text.StringBuilder(enumDirectoryPathLength)
        Dim intNewStringLength As Integer
        intNewStringLength = GetShortPathName(strPath, strStringBuilder, enumDirectoryPathLength)
        Return strStringBuilder.ToString
    End Function

    Public Function GetLongPathName(ByVal strPath As String, Optional ByVal enumDirectoryPathLength As DirectoryPathLength = DirectoryPathLength.WindowsXP) As String
        Dim strStringBuilder As New System.Text.StringBuilder(enumDirectoryPathLength)
        Dim intNewStringLength As Integer
        intNewStringLength = GetLongPathName(strPath, strStringBuilder, enumDirectoryPathLength)
        Return strStringBuilder.ToString
    End Function</pre>]]></content:encoded>
      <snippet:downloads>10</snippet:downloads>
      <snippet:rating>5</snippet:rating>
      <snippet:language>VB.NET</snippet:language>
    </item>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=1160c225-f161-4d64-8503-10e832289a48</guid>
      <title>Sending Mail through authenticated SMTP server</title>
      <link>/PreviewSnippet.aspx?SnippetID=1160c225-f161-4d64-8503-10e832289a48</link>
      <description>Sending Mail through authenticated SMTP server [C#]</description>
      <author>Prasad GVL</author>
      <pubDate>Thu, 02 Jun 2005 00:38:01 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=1160c225-f161-4d64-8503-10e832289a48#comments</comments>
      <category>05d0a09e-56f8-4801-9132-4efc8674eae6</category>
      <dc:title>Sending Mail through authenticated SMTP server</dc:title>
      <dc:date>6/2/2005 12:38:01 AM</dc:date>
      <dc:creator>Prasad GVL</dc:creator>
      <content:encoded><![CDATA[<pre>        /// <summary>
        /// Prepares and sends an EMail
        /// </summary>
        /// <param name="sToAddress">Recipient(s), multiple recipients should be separated by ;</param>
        /// <param name="sFromAddress">Sender address</param>
        /// <param name="sCC">CC address</param>
        /// <param name="sSubject">Subject of Mail</param>
        /// <param name="sMessage">Body of Mail</param>
        /// <param name="sSMTPServer">Which server to use to send mail</param>
        /// <param name="bIsAuthReq">Boolean, indicating if authentication required for this server</param>
        /// <param name="sUserName">String, specifies UserName to login to SMTP Server</param>
        /// <param name="sPassword">String, specifies Password to login to SMTP Server</param>
        /// <returns>Success status(true/false)</returns>
        public static bool SendEMail(string sToAddress, string sFromAddress, string sCC, string sSubject, 
                            string sMessage, string sSMTPServer, bool bIsAuthReq, string sUserName, string sPassword)
        {
            MailMessage mmMessage=new MailMessage();

            mmMessage.To=sToAddress;
            mmMessage.From=sFromAddress;
            if (sCC.Length>0)
                mmMessage.Cc=sCC;
            mmMessage.Subject=sSubject;
            mmMessage.Priority=MailPriority.High;
            mmMessage.BodyFormat=MailFormat.Html;
            mmMessage.Body=sMessage;

            //Check whether target SMTP server requires authentication.
            //If yes, get authentication details from configuration settings.
            if (bIsAuthReq)
            {
                mmMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");  //basic authentication
                mmMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", sUserName); //set username 
                mmMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", sPassword); //Set password 
            }

            try
            {
                SmtpMail.SmtpServer=sSMTPServer;
                SmtpMail.Send(mmMessage);
                return(true);
            }
            catch(Exception ex)
            {
                String sErr=ex.Message;
                return(false);
            }
        }</pre>]]></content:encoded>
      <snippet:downloads>26</snippet:downloads>
      <snippet:rating>5</snippet:rating>
      <snippet:language>C#</snippet:language>
    </item>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=e61e0471-189a-4476-898b-2112955146f2</guid>
      <title>One Way Hash for strings</title>
      <link>/PreviewSnippet.aspx?SnippetID=e61e0471-189a-4476-898b-2112955146f2</link>
      <description>One Way Hash for strings [C#]</description>
      <author>Patrick Bounaix</author>
      <pubDate>Thu, 19 May 2005 16:18:28 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=e61e0471-189a-4476-898b-2112955146f2#comments</comments>
      <category>8cb6de83-1dca-44e9-964e-1bca7209fada</category>
      <dc:title>One Way Hash for strings</dc:title>
      <dc:date>5/19/2005 4:18:28 PM</dc:date>
      <dc:creator>Patrick Bounaix</dc:creator>
      <content:encoded><![CDATA[<pre>#region OneWayHash
		/// <summary>
		/// Encrypts input string
		/// </summary>
		/// <param name="input">string</param>
		/// <returns>string</returns>
		public string OneWayHash(string input)
		{
			// convert pwd into hashed value //
			HashAlgorithm HA = new SHA1Managed();
			//declare a new encoder
			UTF8Encoding UTF8Encoder = new UTF8Encoding();
			//get byte representation of input text
			byte[] inputBytes = UTF8Encoder.GetBytes(input);
			//hash the input byte array
			byte[] output = HA.ComputeHash(inputBytes);
			//convert output byte array to a string
			string newString  = Convert.ToBase64String(output);
			return newString;
		}
		#endregion</pre>]]></content:encoded>
      <snippet:downloads>16</snippet:downloads>
      <snippet:rating>5</snippet:rating>
      <snippet:language>C#</snippet:language>
    </item>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=aea6cbda-32c4-4abc-b30b-313b2e747383</guid>
      <title>Formating a file size and adding the B, KB, MB and GB extension appropriately with string.Format</title>
      <link>/PreviewSnippet.aspx?SnippetID=aea6cbda-32c4-4abc-b30b-313b2e747383</link>
      <description>Formating a file size and adding the B, KB, MB and GB extension appropriately with string.Format [C#]</description>
      <author>J.Marc Piulachs</author>
      <pubDate>Thu, 12 May 2005 19:03:39 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=aea6cbda-32c4-4abc-b30b-313b2e747383#comments</comments>
      <category>427a3023-1009-4fad-8108-77d5eea21bd1</category>
      <dc:title>Formating a file size and adding the B, KB, MB and GB extension appropriately with string.Format</dc:title>
      <dc:date>5/12/2005 7:03:39 PM</dc:date>
      <dc:creator>J.Marc Piulachs</dc:creator>
      <content:encoded><![CDATA[<pre>private string FormatSize (double fileSize)
{
	if (fileSize < 1024)
		return String.Format("{0:N0} B", fileSize);
	else if (fileSize < 1024*1024)
		return String.Format("{0:N2} KB", fileSize/1024);
	else
		return String.Format("{0:N2} MB", fileSize/(1024*1024));
}</pre>]]></content:encoded>
      <snippet:downloads>204</snippet:downloads>
      <snippet:rating>5</snippet:rating>
      <snippet:language>C#</snippet:language>
    </item>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=0adf7cd7-de8c-4bb6-b3c9-34ed37498e04</guid>
      <title>How do I load an image from a URI address?</title>
      <link>/PreviewSnippet.aspx?SnippetID=0adf7cd7-de8c-4bb6-b3c9-34ed37498e04</link>
      <description>How do I load an image from a URI address? [VB.NET]</description>
      <author>J.Marc Piulachs</author>
      <pubDate>Mon, 18 Apr 2005 08:59:22 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=0adf7cd7-de8c-4bb6-b3c9-34ed37498e04#comments</comments>
      <category>aeb15495-509d-43ee-9bb5-f59c47bca5ff</category>
      <dc:title>How do I load an image from a URI address?</dc:title>
      <dc:date>4/18/2005 8:59:22 AM</dc:date>
      <dc:creator>J.Marc Piulachs</dc:creator>
      <content:encoded><![CDATA[<pre>Function GetImageFromURL(ByVal url As String) As Byte() 
    Dim wr As HttpWebRequest = _ 
       DirectCast(WebRequest.Create(url), HttpWebRequest) 
    Dim wresponse As HttpWebResponse = _ 
       DirectCast(wr.GetResponse, HttpWebResponse) 
    Dim responseStream As Stream = wresponse.GetResponseStream 
    Dim br As BinaryReader = New BinaryReader(responseStream) 
    Dim bytesize As Long = wresponse.ContentLength 
    Return br.ReadBytes(bytesize) 
End Function 
To use the above function:
Dim img As New Bitmap(New IO.MemoryStream(GetImageFromURL("http://msdn.microsoft.com/longhorn/art/codenameLonghorn.JPG"))) 
Me.BackgroundImage = img 
</pre>]]></content:encoded>
      <snippet:downloads>9</snippet:downloads>
      <snippet:rating>5</snippet:rating>
      <snippet:language>VB.NET</snippet:language>
    </item>
  </channel>
</rss>