VB.NET - Performing File operations using Path class



Working with in built functions in Path class

Imports System.IO

Private Sub PathClass()
        Dim strFileName As String = "C:\Hima\SyntaxHelp.txt"

        'Shows SyntaxHelp.txt
        MessageBox.Show("File Name " & Path.GetFileName(strFileName))

        'Shows .txt
         MessageBox.Show("File Extension " &Path.GetExtension(strFileName))

        'Shows SyntaxHelp
         MessageBox.Show("File with out extension " & Path.GetFileNameWithoutExtension(strFileName))

        'Shows C:\Hima\SyntaxHelp.txt
         MessageBox.Show("File with Full Path " &Path.GetFullPath(strFileName))

        'Shows C:\Hima
         MessageBox.Show(Path.GetDirectoryName(strFileName))
       End Sub

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.