Filesystem: Add GetDateDirectory and GetFilenameWithSuffix
This commit is contained in:
parent
35fadb4ca9
commit
ca87457fd1
@ -348,4 +348,36 @@ Public Class File
|
|||||||
Return oIsDirectory
|
Return oIsDirectory
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function GetDateDirectory(pBaseDirectory As String) As String
|
||||||
|
Dim oDateDirectory = GetDateString()
|
||||||
|
Dim oFinalDirectory As String = IO.Path.Combine(pBaseDirectory, oDateDirectory)
|
||||||
|
|
||||||
|
If IO.Directory.Exists(oFinalDirectory) = False Then
|
||||||
|
Try
|
||||||
|
Directory.CreateDirectory(oFinalDirectory)
|
||||||
|
Catch ex As Exception
|
||||||
|
_Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return oFinalDirectory
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function GetDateString() As String
|
||||||
|
Return $"{Now:yyyy\\MM\\dd}"
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function GetDateTimeString() As String
|
||||||
|
Return $"{Now:yyyy-MM-dd_hh-mm-ffff}"
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function GetFilenameWithSuffix(pFilePath As String, pSuffix As String)
|
||||||
|
Dim oFileInfo = New IO.FileInfo(pFilePath)
|
||||||
|
Return GetFilenameWithSuffix(IO.Path.GetFileNameWithoutExtension(pFilePath), pSuffix, oFileInfo.Extension.Substring(1))
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function GetFilenameWithSuffix(pBaseString As String, pSuffix As String, pExtension As String)
|
||||||
|
Return $"{pBaseString}-{pSuffix}.{pExtension}"
|
||||||
|
End Function
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user