자료실

부자는 돈을 써서 시간을 아끼지만 가난한 사람은 시간을 써서 돈을 아낀다

vb.net

IT HUB를 찾아주셔서 감사합니다.

기타 Get the file name from the full path in VB.Net

페이지 정보

profile_image
작성자 하나를하더라도최선을
댓글 0건 조회 2,948회 작성일 23-09-06 13:31

본문

In the below there are two methods that can be use to extract the file name from the full file path.

Using System.IO.Path.GetFileName
The following method is using the System.IO.Path.GetFileName that returns the file name and extension of the specified path string.

Private Function GetFileName(ByVal path As String) As String


   Dim _filename As String = System.IO.Path.GetFileName(path)


   Return _filename


End Function

Using Split() method

In this method we are splitting the specified path string with the separators and pick the last string from the returned array of spitted string.

Private Function GetFileName_OtherMethod(ByVal path As String) As String


    Dim _filename As String = ""


    Dim sep() As Char = {"/", "\", "//"}


    _filename = path.Split(sep).Last()


    Return _filename


End Function

댓글목록

등록된 댓글이 없습니다.