Horkay Blog
The postings on this site are my own and do not represent my Employer's positions, advice or strategies.
Tuesday, November 20, 2007

Such a simple task, but one that trips me up each time.  I can do it very easily in TSQL, but sometimes i have to do it in .net scripting, vb or c#.

I tried using Regex below but was just too tired to fight beyound what I had...any help, the old vb.net standard function is what i ended up using...

Dim MyRegex as Regex = New Regex( "[^/]+$", RegexOptions.RightToLeft )

-------------

    Private Function GetNameNoPathorExt(ByVal FileNameWithPath) As String
        Dim sTemp As String
        Dim iPos As Integer

        iPos = InStr(FileNameWithPath, ".")
        If iPos > 1 Then
            sTemp = Left$(FileNameWithPath, iPos - 1)
        Else
            sTemp = FileNameWithPath
        End If

        iPos = InStrRev(sTemp, "\")
        If iPos > 1 Then
            sTemp = Right$(sTemp, Len(sTemp) - iPos)
        End If

        Return sTemp
    End Function

Tuesday, November 20, 2007 8:06:32 PM (Central Standard Time, UTC-06:00) | Comments [0] |  RegEx#
Comments are closed.
Search
Popular Posts
Unpatched Vulnerabiltiy discovered ...
Spring Fornicator brewed...
TOE, Packet Loss, Blue Screen crash...
Bravo base to Ghost rider tango
Error installing Cumulative Update ...
Recent Posts
Archive
Links
Categories
Admin Login
Sign In
Blogroll