<?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: User Contributed Snippets</title>
    <link>http://www.codexchange.org</link>
    <description>Summary of the snippets published by a codexchange user</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>Thu, 15 Oct 2026 09:18:58 GMT</lastBuildDate>
    <ttl>20</ttl>
    <dc:language>en-us</dc:language>
    <dc:rights>Copyright © CodeXchange, 2004-2006</dc:rights>
    <dc:date>10/15/2026 9:18:58 AM</dc:date>
    <dc:publisher />
    <dc:creator>CodeXchange RSS Feed Generator v1.0</dc:creator>
    <item>
      <guid>/PreviewSnippet.aspx?SnippetID=ac4ef358-4ea7-42fc-979b-b259e28a0761</guid>
      <title>Get the file extension from a file path or file name</title>
      <link>/PreviewSnippet.aspx?SnippetID=ac4ef358-4ea7-42fc-979b-b259e28a0761</link>
      <description>Get the file extension from a file path or file name [VB.NET]</description>
      <author>Antonio Cosano</author>
      <pubDate>Fri, 17 Sep 2010 05:42:05 GMT</pubDate>
      <comments>/PreviewSnippet.aspx?SnippetID=ac4ef358-4ea7-42fc-979b-b259e28a0761#comments</comments>
      <category>def21cf5-7419-48cb-a8b7-ceb74299c62a</category>
      <dc:title>Get the file extension from a file path or file name</dc:title>
      <dc:date>9/17/2010 5:42:05 AM</dc:date>
      <dc:creator>Antonio Cosano</dc:creator>
      <content:encoded><![CDATA[<pre>Imports Microsoft.Win32
Imports System.IO
' How to call the function
' Get the file extension from a file path or file name
'  -> Dim Extension As String = Path.GetExtension("hello.mp3")
' Get the file type from the extension
' -> Dim FileType = GetFileType(Extension)
Public Shared Function GetFileType(ByVal fileExtension As String) As String
		Dim fileType As String = String.Empty
		'Search all keys under HKEY_CLASSES_ROOT
		For Each subKey As String In Registry.ClassesRoot.GetSubKeyNames()
			If String.IsNullOrEmpty(subKey) Then
				Continue For
			End If
			If subKey.CompareTo(fileExtension) = 0 Then
				'File extension found. Get Default Value
				Dim defaultValue As String = Registry.ClassesRoot.OpenSubKey(subKey).GetValue("").ToString()
				If defaultValue.Length = 0 Then
					'No File Type specified
					Exit For
				End If
				If fileType.Length = 0 Then
					'Get Initial File Type and search for the full File Type Description
					fileType = defaultValue
					fileExtension = fileType
				Else
					'File Type Description found
					If defaultValue.Length > 0 Then
						fileType = defaultValue
					End If
					Exit For
				End If
			End If
		Next
		Return fileType
	End Function</pre>]]></content:encoded>
      <snippet:downloads>0</snippet:downloads>
      <snippet:rating>0</snippet:rating>
      <snippet:language>VB.NET</snippet:language>
    </item>
  </channel>
</rss>