TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

<< Back to VBNET

VB.NET Path.GetExtension: File Extension

Get the file extension of a path String. The extension includes the leading period.
File extension. A file has an optional extension. It occurs at the end of the file name. With the Path.GetExtension Function we acquire the extension. We then make decisions based on its value. This method has some interesting behavior.File
In this example, you can see that the string literal contains a Windows file system path. Next, the extension is extracted by invoking the Path.GetExtension method. You pass the string reference to this function as an argument.

Finally: The program shows exactly what the extension is. The period is included at the start of the three-character extension.

VB.NET program that uses Path.GetExtension Imports System.IO Module Module1 Sub Main() ' Input path. Dim p As String = "C:\Users\Sam\Documents\Test.txt" ' Get extension. Dim extension As String = Path.GetExtension(p) ' Display extension. Console.WriteLine(extension) Console.WriteLine(".txt" = extension) End Sub End Module Output .txt True
When using Path.GetExtension, developers may assume the period is not included in the extension string. To compare the extension string, you must use a string literal such as ".txt" with the period prefixing the three letters.PathStrings
Summary. With the Path.GetExtension function in the VB.NET language, you can quickly and reliably determine what the extension of a file name or path is. Many inputs are accepted by this function. It allows for many different formats of paths.
© TheDeveloperBlog.com
The Dev Codes

Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf