<?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: Most Downloaded Snippets</title>
    <link>http://www.codexchange.org</link>
    <description>Summary of the most downloaded 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>Tue, 18 Jun 2013 16:36:19 GMT</lastBuildDate>
    <ttl>20</ttl>
    <dc:language>en-us</dc:language>
    <dc:rights>Copyright © CodeXchange, 2004-2006</dc:rights>
    <dc:date>6/18/2013 4:36:19 PM</dc:date>
    <dc:publisher />
    <dc:creator>CodeXchange RSS Feed Generator v1.0</dc:creator>
    <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=15e5dde4-2f16-4dee-8760-5a9325835ebf</guid>
      <title>INI File Access</title>
      <link>/PreviewSnippet.aspx?SnippetID=15e5dde4-2f16-4dee-8760-5a9325835ebf</link>
      <description>INI File Access [VB.NET]</description>
      <author>Renan Feria</author>
      <pubDate>Fri, 13 May 2005 01:03:59 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=15e5dde4-2f16-4dee-8760-5a9325835ebf#comments</comments>
      <category>03af4393-69f0-4f95-8d4c-60efe508c790</category>
      <dc:title>INI File Access</dc:title>
      <dc:date>5/13/2005 1:03:59 AM</dc:date>
      <dc:creator>Renan Feria</dc:creator>
      <content:encoded><![CDATA[<pre>'SAMPLE USAGE
'clsFileAccess_INI.vb
'Dim sFilename As String
'Dim sTemp As String
'sFilename = g_strINFile
'Dim cReadINI As New clsFileAccess_INI(sFilename)
'		If Len(Dir(sFilename)) <> 0 Then
'			cReadINI.Filename = sFilename
'			g_CONNECTION.SERVER_NAME = cReadINI.ReadString(CONNECT, "SERVER", "(local)")
'			g_CONNECTION.DATABASE = cReadINI.ReadString(CONNECT, "DATABASE")
'			g_CONNECTION.USERNAME = cReadINI.ReadString(CONNECT, "USERNAME", "sa")
'			g_CONNECTION.PASSWORD = cReadINI.ReadString(CONNECT, "PASSWORD", "sa")
'			g_CONNECTION.SECURITY = cReadINI.ReadString(CONNECT, "SECURITY", "0")
'			REPORT_PATH = cReadINI.ReadString("REPORTS", "ReportPath", Application.StartupPath & IIf(Right(Application.StartupPath, 2) = "\", "", "\"))
'			REPORT_EXPORT = cReadINI.ReadString("REPORTS", "ExportPath", Application.StartupPath & IIf(Right(Application.StartupPath, 2) = "\", "", "\"))
'			sTemp &= ""
'			sTemp &= "Data Source=" & g_CONNECTION.SERVER_NAME & ";"
'			sTemp &= "Initial Catalog=" & g_CONNECTION.DATABASE & ";"
'			sTemp &= "User ID=" & g_CONNECTION.USERNAME & ";"
'			sTemp &= "password=" & g_CONNECTION.PASSWORD & ";"
'       End If

Imports System
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Collections
Imports Microsoft.VisualBasic
Public Class clsFileAccess_INI
    ' <API-DECLARES>
    <DllImport("KERNEL32.DLL", EntryPoint:="GetPrivateProfileIntA", SetLastError:=False, CharSet:=CharSet.ANSI, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Private Shared Function GetPrivateProfileInt(ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
    End Function
    <DllImport("KERNEL32.DLL", EntryPoint:="WritePrivateProfileStringA", SetLastError:=False, CharSet:=CharSet.ANSI, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Private Shared Function WritePrivateProfileString(ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
    End Function
    <DllImport("KERNEL32.DLL", EntryPoint:="GetPrivateProfileStringA", SetLastError:=False, CharSet:=CharSet.ANSI, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Private Shared Function GetPrivateProfileString(ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
    End Function
    <DllImport("KERNEL32.DLL", EntryPoint:="WritePrivateProfileStructA", SetLastError:=False, CharSet:=CharSet.ANSI, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Private Shared Function WritePrivateProfileStruct(ByVal lpszSection As String, ByVal lpszKey As String, ByVal lpStruct() As Byte, ByVal uSizeStruct As Integer, ByVal szFile As String) As Integer
    End Function
    <DllImport("KERNEL32.DLL", EntryPoint:="GetPrivateProfileStructA", SetLastError:=False, CharSet:=CharSet.ANSI, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Private Shared Function GetPrivateProfileStruct(ByVal lpszSection As String, ByVal lpszKey As String, ByVal lpStruct() As Byte, ByVal uSizeStruct As Integer, ByVal szFile As String) As Integer
    End Function
    <DllImport("KERNEL32.DLL", EntryPoint:="GetPrivateProfileSectionNamesA", SetLastError:=False, CharSet:=CharSet.ANSI, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Private Shared Function GetPrivateProfileSectionNames(ByVal lpszReturnBuffer() As Byte, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
    End Function
    <DllImport("KERNEL32.DLL", EntryPoint:="WritePrivateProfileSectionA", SetLastError:=False, CharSet:=CharSet.ANSI, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Private Shared Function WritePrivateProfileSection(ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
    End Function
    ' </API-DECLARES>
    '/// <summary>Constructs a new INIReader object.</summary>
    '/// <param name="File">Specifies the INI file to use.</param>
    Public Sub New(ByVal File As String)
        Filename = File
    End Sub
    '/// <summary>Specifies the INI file to use.</summary>
    '/// <value>A <see cref="String">String</see> representing the full path of the INI file.</value>
    Public Property Filename() As String
        Get
            Return m_Filename
        End Get
        Set(ByVal Value As String)
            m_Filename = Value
        End Set
    End Property
    '/// <summary>Specifies the section you're working in. (aka 'the active section')</summary>
    '/// <value>A <see cref="String">String</see> representing the section you're working in.</value>
    Public Property Section() As String
        Get
            Return m_Section
        End Get
        Set(ByVal Value As String)
            m_Section = Value
        End Set
    End Property
    '/// <summary>Reads an <see cref="Int32">Integer</see> from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="DefVal">Specifies the value to return if the specified key isn't found.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns the default value if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Overloads Function ReadInteger(ByVal Section As String, ByVal Key As String, ByVal DefVal As Integer) As Integer
        Try
            Return GetPrivateProfileInt(Section, Key, DefVal, Filename)
        Catch
            Return DefVal
        End Try
    End Function
    '/// <summary>Reads an <see cref="Int32">Integer</see> from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns 0 if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Overloads Function ReadInteger(ByVal Section As String, ByVal Key As String) As Integer
        Return ReadInteger(Section, Key, 0)
    End Function
    '/// <summary>Reads an <see cref="Int32">Integer</see> from the specified key of the active section.</summary>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="DefVal">Specifies the section to search in.</param>
    '/// <returns>Returns the value of the specified Key, or returns the default value if the specified Key isn't found in the active section of the INI file.</returns>
    Public Overloads Function ReadInteger(ByVal Key As String, ByVal DefVal As Integer) As Integer
        Return ReadInteger(Section, Key, DefVal)
    End Function
    '/// <summary>Reads an <see cref="Int32">Integer</see> from the specified key of the active section.</summary>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <returns>Returns the value of the specified Key, or returns 0 if the specified Key isn't found in the active section of the INI file.</returns>
    Public Overloads Function ReadInteger(ByVal Key As String) As Integer
        Return ReadInteger(Key, 0)
    End Function
    '/// <summary>Reads a <see cref="String">String</see> from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="DefVal">Specifies the value to return if the specified key isn't found.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns the default value if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Overloads Function ReadString(ByVal Section As String, ByVal Key As String, ByVal DefVal As String) As String
        Try
            Dim sb As New StringBuilder(MAX_ENTRY)
            Dim Ret As Integer = GetPrivateProfileString(Section, Key, DefVal, sb, MAX_ENTRY, Filename)
            Return sb.ToString
        Catch
            Return DefVal
        End Try
    End Function
    '/// <summary>Reads a <see cref="String">String</see> from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns an empty String if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Overloads Function ReadString(ByVal Section As String, ByVal Key As String) As String
        Return ReadString(Section, Key, "")
    End Function
    '/// <summary>Reads a <see cref="String">String</see> from the specified key of the active section.</summary>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <returns>Returns the value of the specified Key, or returns an empty String if the specified Key isn't found in the active section of the INI file.</returns>
    Public Overloads Function ReadString(ByVal Key As String) As String
        Return ReadString(Section, Key)
    End Function
    '/// <summary>Reads a <see cref="Int64">Long</see> from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="DefVal">Specifies the value to return if the specified key isn't found.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns the default value if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Overloads Function ReadLong(ByVal Section As String, ByVal Key As String, ByVal DefVal As Long) As Long
        Return Long.Parse(ReadString(Section, Key, DefVal.ToString))
    End Function
    '/// <summary>Reads a <see cref="Int64">Long</see> from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns 0 if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Overloads Function ReadLong(ByVal Section As String, ByVal Key As String) As Long
        Return ReadLong(Section, Key, 0)
    End Function
    '/// <summary>Reads a <see cref="Int64">Long</see> from the specified key of the active section.</summary>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="DefVal">Specifies the section to search in.</param>
    '/// <returns>Returns the value of the specified Key, or returns the default value if the specified Key isn't found in the active section of the INI file.</returns>
    Public Overloads Function ReadLong(ByVal Key As String, ByVal DefVal As Long) As Long
        Return ReadLong(Section, Key, DefVal)
    End Function
    '/// <summary>Reads a <see cref="Int64">Long</see> from the specified key of the active section.</summary>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <returns>Returns the value of the specified Key, or returns 0 if the specified Key isn't found in the active section of the INI file.</returns>
    Public Overloads Function ReadLong(ByVal Key As String) As Long
        Return ReadLong(Key, 0)
    End Function
    '/// <summary>Reads a <see cref="Byte">Byte</see> array from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="Length">Specifies the value to return if the specified key isn't found.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns Nothing (Null in C#, C++.NET) if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Function ReadByteArray(ByVal Section As String, ByVal Key As String, ByVal Length As Integer) As Byte()
        If Length > 0 Then
            Try
                Dim Buffer(Length - 1) As Byte
                If GetPrivateProfileStruct(Section, Key, Buffer, Buffer.Length, Filename) = 0 Then
                    Return Nothing
                Else
                    Return Buffer
                End If
            Catch
                Return Nothing
            End Try
        End If
    End Function
    '/// <summary>Reads a <see cref="Byte">Byte</see> array from the specified key of the active section.</summary>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="Length">Specifies the value to return if the specified key isn't found.</param>
    '/// <returns>Returns the value of the specified Key, or returns Nothing (Null in C#, C++.NET) if the specified Key pair isn't found in the active section of the INI file.</returns>
    Public Function ReadByteArray(ByVal Key As String, ByVal Length As Integer) As Byte()
        Return ReadByteArray(Section, Key, Length)
    End Function
    '/// <summary>Reads a <see cref="Boolean">Boolean</see> from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="DefVal">Specifies the value to return if the specified key isn't found.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns the default value if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Overloads Function ReadBoolean(ByVal Section As String, ByVal Key As String, ByVal DefVal As Boolean) As Boolean
        Return Boolean.Parse(ReadString(Section, Key, DefVal.ToString))
    End Function
    '/// <summary>Reads a <see cref="Boolean">Boolean</see> from the specified key of the specified section.</summary>
    '/// <param name="Section">Specifies the section to search in.</param>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <returns>Returns the value of the specified Section/Key pair, or returns False if the specified Section/Key pair isn't found in the INI file.</returns>
    Public Overloads Function ReadBoolean(ByVal Section As String, ByVal Key As String) As Boolean
        Return ReadBoolean(Section, Key, False)
    End Function
    '/// <summary>Reads a <see cref="Boolean">Boolean</see> from the specified key of the specified section.</summary>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <param name="DefVal">Specifies the value to return if the specified key isn't found.</param>
    '/// <returns>Returns the value of the specified Key pair, or returns the default value if the specified Key isn't found in the active section of the INI file.</returns>
    Public Overloads Function ReadBoolean(ByVal Key As String, ByVal DefVal As Boolean) As Boolean
        Return ReadBoolean(Section, Key, DefVal)
    End Function
    '/// <summary>Reads a <see cref="Boolean">Boolean</see> from the specified key of the specified section.</summary>
    '/// <param name="Key">Specifies the key from which to return the value.</param>
    '/// <returns>Returns the value of the specified Key, or returns False if the specified Key isn't found in the active section of the INI file.</returns>
    Public Overloads Function ReadBoolean(ByVal Key As String) As Boolean
        Return ReadBoolean(Section, Key)
    End Function
    '/// <summary>Writes an <see cref="Integer">Integer</see> to the specified key in the specified section.</summary>
    '/// <param name="Section">Specifies the section to write in.</param>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Section As String, ByVal Key As String, ByVal Value As Integer) As Boolean
        Try
            Return (WritePrivateProfileString(Section, Key, Value.ToString, Filename) <> 0)
        Catch
            Return False
        End Try
    End Function
    '/// <summary>Writes an <see cref="Integer">Integer</see> to the specified key in the active section.</summary>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Key As String, ByVal Value As Integer) As Boolean
        Return Write(Section, Key, Value)
    End Function
    '/// <summary>Writes a <see cref="String">String</see> to the specified key in the specified section.</summary>
    '/// <param name="Section">Specifies the section to write in.</param>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Section As String, ByVal Key As String, ByVal Value As String) As Boolean
        Try
            Return (WritePrivateProfileString(Section, Key, Value, Filename) <> 0)
        Catch
            Return False
        End Try
    End Function
    '/// <summary>Writes a <see cref="String">String</see> to the specified key in the active section.</summary>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Key As String, ByVal Value As String) As Boolean
        Return Write(Section, Key, Value)
    End Function
    '/// <summary>Writes a <see cref="Long">Long</see> to the specified key in the specified section.</summary>
    '/// <param name="Section">Specifies the section to write in.</param>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Section As String, ByVal Key As String, ByVal Value As Long) As Boolean
        Return Write(Section, Key, Value.ToString)
    End Function
    '/// <summary>Writes a <see cref="Long">Long</see> to the specified key in the active section.</summary>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Key As String, ByVal Value As Long) As Boolean
        Return Write(Section, Key, Value)
    End Function
    '/// <summary>Writes a <see cref="Byte">Byte</see> array to the specified key in the specified section.</summary>
    '/// <param name="Section">Specifies the section to write in.</param>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Section As String, ByVal Key As String, ByVal Value() As Byte) As Boolean
        Try
            Return (WritePrivateProfileStruct(Section, Key, Value, Value.Length, Filename) <> 0)
        Catch
            Return False
        End Try
    End Function
    '/// <summary>Writes a <see cref="Byte">Byte</see> array to the specified key in the active section.</summary>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Key As String, ByVal Value() As Byte) As Boolean
        Return Write(Section, Key, Value)
    End Function
    '/// <summary>Writes a <see cref="Boolean">Boolean</see> to the specified key in the specified section.</summary>
    '/// <param name="Section">Specifies the section to write in.</param>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Section As String, ByVal Key As String, ByVal Value As Boolean) As Boolean
        Return Write(Section, Key, Value.ToString)
    End Function
    '/// <summary>Writes a <see cref="Boolean">Boolean</see> to the specified key in the active section.</summary>
    '/// <param name="Key">Specifies the key to write to.</param>
    '/// <param name="Value">Specifies the value to write.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Overloads Function Write(ByVal Key As String, ByVal Value As Boolean) As Boolean
        Return Write(Section, Key, Value)
    End Function
    '/// <summary>Deletes a key from the specified section.</summary>
    '/// <param name="Section">Specifies the section to delete from.</param>
    '/// <param name="Key">Specifies the key to delete.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Function DeleteKey(ByVal Section As String, ByVal Key As String) As Boolean
        Try
            Return (WritePrivateProfileString(Section, Key, Nothing, Filename) <> 0)
        Catch
            Return False
        End Try
    End Function
    '/// <summary>Deletes a key from the active section.</summary>
    '/// <param name="Key">Specifies the key to delete.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Function DeleteKey(ByVal Key As String) As Boolean
        Try
            Return (WritePrivateProfileString(Section, Key, Nothing, Filename) <> 0)
        Catch
            Return False
        End Try
    End Function
    '/// <summary>Deletes a section from an INI file.</summary>
    '/// <param name="Section">Specifies the section to delete.</param>
    '/// <returns>Returns True if the function succeeds, False otherwise.</returns>
    Public Function DeleteSection(ByVal Section As String) As Boolean
        Try
            Return WritePrivateProfileSection(Section, Nothing, Filename) <> 0
        Catch
            Return False
        End Try
    End Function
    '/// <summary>Retrieves a list of all available sections in the INI file.</summary>
    '/// <returns>Returns an <see cref="ArrayList">ArrayList</see> with all available sections.</returns>
    Public Function GetSectionNames() As ArrayList
        GetSectionNames = New ArrayList
        Dim Buffer(MAX_ENTRY) As Byte
        Dim BuffStr As String
        Dim PrevPos As Integer = 0
        Dim Length As Integer
        Try
            Length = GetPrivateProfileSectionNames(Buffer, MAX_ENTRY, Filename)
        Catch
            Exit Function
        End Try
        Dim ASCII As New ASCIIEncoding
        If Length > 0 Then
            BuffStr = ASCII.GetString(Buffer)
            Length = 0
            PrevPos = -1
            Do
                Length = BuffStr.IndexOf(ControlChars.NullChar, PrevPos + 1)
                If Length - PrevPos = 1 OrElse Length = -1 Then Exit Do
                Try
                    GetSectionNames.Add(BuffStr.Substring(PrevPos + 1, Length - PrevPos))
                Catch
                End Try
                PrevPos = Length
            Loop
        End If
    End Function
    'Private variables and constants
    Private m_Filename As String
    Private m_Section As String
    Private Const MAX_ENTRY As Integer = 32768
End Class
</pre>]]></content:encoded>
      <snippet:downloads>166</snippet:downloads>
      <snippet:rating>3</snippet:rating>
      <snippet:language>VB.NET</snippet:language>
    </item>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=67f1e57f-619e-4e8c-91b8-602ff5dd77d2</guid>
      <title>Read XML from string into DataSet</title>
      <link>/PreviewSnippet.aspx?SnippetID=67f1e57f-619e-4e8c-91b8-602ff5dd77d2</link>
      <description>Read XML from string into DataSet [C#]</description>
      <author>Martin Chundela</author>
      <pubDate>Fri, 13 May 2005 06:57:30 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=67f1e57f-619e-4e8c-91b8-602ff5dd77d2#comments</comments>
      <category>e5dc5661-427e-4d33-8be6-187bd2783223</category>
      <dc:title>Read XML from string into DataSet</dc:title>
      <dc:date>5/13/2005 6:57:30 AM</dc:date>
      <dc:creator>Martin Chundela</dc:creator>
      <content:encoded><![CDATA[<pre>DataSet ds = new DataSet("DataSetName");
			System.IO.StringReader sr = new System.IO.StringReader(XMLString);
			ds.ReadXml(sr);</pre>]]></content:encoded>
      <snippet:downloads>156</snippet:downloads>
      <snippet:rating>3</snippet:rating>
      <snippet:language>C#</snippet:language>
    </item>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=b2f8954a-7639-46c6-908a-f3afe6907079</guid>
      <title>Create Manifest File for your Application</title>
      <link>/PreviewSnippet.aspx?SnippetID=b2f8954a-7639-46c6-908a-f3afe6907079</link>
      <description>Create Manifest File for your Application [VB.NET]</description>
      <author>Renan Feria</author>
      <pubDate>Fri, 13 May 2005 00:51:59 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=b2f8954a-7639-46c6-908a-f3afe6907079#comments</comments>
      <category>03af4393-69f0-4f95-8d4c-60efe508c790</category>
      <dc:title>Create Manifest File for your Application</dc:title>
      <dc:date>5/13/2005 12:51:59 AM</dc:date>
      <dc:creator>Renan Feria</dc:creator>
      <content:encoded><![CDATA[<pre>	'//**************************************
	'   //     
	'   // Name: A Function To Create Manifest F
	'   //     iles At Runtime
	'   // Description:No More Creating Manifest
	'   //     Files. Just Put This Code In Your Projec
	'   //     t And it Will AutoMaticly Make 1 If Ther
	'   //     e isnt 1 there.
	'   // By: Christopher Hemple
	'   //
	'   // Inputs:None ;o.
	'   //
	'   // Returns:Xp Look!
	'   //
	'   // Assumes:Just Run This Function On For
	'   //     m Load, Thats It :D.
	'   //
	'   // Side Effects:None :P.
	'   //
	'   //This code is copyrighted and has    // limited warranties.Please see http://
	'   //     www.Planet-Source-Code.com/vb/scripts/Sh
	'   //     owCode.asp?txtCodeId=515&lngWId=10    //for details.    //**************************************
	'   //     
	Function Manifest()
		'If File.Exists(Application.StartupPath & "\" & Application.ProductName & ".exe.manifest") = True Then
		'	Exit Function
		'Else
			'Generate File Content
			Dim Content As String
			Dim bl As String = vbCrLf
			Content = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" & bl
			Content &= "<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>" & bl
			Content &= "<assemblyIdentity" & bl
			Content &= "version='1.0.0.0'" & bl
			Content &= "processorArchitecture='X86'" & bl
			Content &= "name='Microsoft.Winweb."
			Content &= Application.ProductName
			Content &= ".exe'" & bl
			Content &= "type='win32'" & bl
			Content &= "/>" & bl
			Content &= "<description>"
			Content &= Application.ProductName
			Content &= "</description>" & bl
			Content &= "<dependency>" & bl
			Content &= "<dependentAssembly>" & bl
			Content &= " <assemblyIdentity" & bl
			Content &= "type='win32'" & bl
			Content &= "name='Microsoft.Windows.Common-Controls'" & bl
			Content &= "version='6.0.0.0'" & bl
			Content &= "processorArchitecture='X86'" & bl
			Content &= "publicKeyToken='6595b64144ccf1df'" & bl
			Content &= "language='*'" & bl
			Content &= " />" & bl
			Content &= "</dependentAssembly>" & bl
			Content &= "</dependency>" & bl
			Content &= "</assembly>"
			'Create Manifest File
		'Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\" & Application.ProductName & ".exe.manifest")
		'sw.Write(Content)
		'sw.Close()
		''Reload Me
		'Shell(Application.StartupPath & "\" & Application.ProductName & ".exe", AppWinStyle.NormalFocus, False)
		'End If
	End Function</pre>]]></content:encoded>
      <snippet:downloads>123</snippet:downloads>
      <snippet:rating>2</snippet:rating>
      <snippet:language>VB.NET</snippet:language>
    </item>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=9710a3d4-2021-4e50-b0b3-caa15848405a</guid>
      <title>Round function to avoid banker's rounding</title>
      <link>/PreviewSnippet.aspx?SnippetID=9710a3d4-2021-4e50-b0b3-caa15848405a</link>
      <description>Round function to avoid banker's rounding [VB.NET]</description>
      <author>Toby Knott</author>
      <pubDate>Mon, 16 May 2005 16:44:34 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=9710a3d4-2021-4e50-b0b3-caa15848405a#comments</comments>
      <category>701a2ecc-98c3-467f-95c7-3274cc59e2f4</category>
      <dc:title>Round function to avoid banker's rounding</dc:title>
      <dc:date>5/16/2005 4:44:34 PM</dc:date>
      <dc:creator>Toby Knott</dc:creator>
      <content:encoded><![CDATA[<pre>' all the framework rounding methods use banker's rounding
' if a number is exactly halfway between two numbers, it will round to the nearest even
' i.e. - 3.5 will round to 4, but 2.5 will round to 2
Function Round(ByVal dVal As Decimal, ByVal lScale As Int32) As Decimal
	Dim lMltply As Int32
	Dim dAdd As Decimal
	' find half of the least significant digit
	dAdd = CType(Math.Pow(0.1, lScale) * 0.5, Decimal)
	If dVal < 0 Then dAdd *= -1
	' initialize multiplier
	lMltply = CType(Math.Pow(10, lScale), Int32)
	' add half of the least significant digit, times the multiplier, truncate,
	' and divide by the multiplier
	Return Decimal.Truncate((dVal + dAdd) * lMltply) / lMltply
End Function</pre>]]></content:encoded>
      <snippet:downloads>81</snippet:downloads>
      <snippet:rating>3</snippet:rating>
      <snippet:language>VB.NET</snippet:language>
    </item>
  </channel>
</rss>