diff --git a/Windream/Windream.vb b/Windream/Windream.vb index bb6de4bf..2e71d39c 100644 --- a/Windream/Windream.vb +++ b/Windream/Windream.vb @@ -638,6 +638,7 @@ Public Class Windream Return False End Try End Function + ''' ''' Archives windream object immediately ''' @@ -654,7 +655,7 @@ Public Class Windream End Try End Function - Public Function NewFolder(Path As String, pExtension As String) As Boolean + Public Function NewFolder(Path As String) As Boolean If Not TestSessionLoggedIn() Then Return False End If @@ -665,13 +666,11 @@ Public Class Windream Dim oFolderObject As WMObject Dim oCurrentPath As String = String.Empty - For Each oFolder In oFolders - If oFolder.ToString.EndsWith(pExtension) Then - Exit For - ElseIf oFolder = String.Empty Then + If oFolder = String.Empty Then Continue For End If + oCurrentPath = Combine(oCurrentPath, oFolder) If TestFolderExists(oCurrentPath) = False Then @@ -706,13 +705,13 @@ Public Class Windream Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean NewDocumentID = 0 - Dim oExtension As String = Path.GetExtension(FilenameSource) If Not TestSessionLoggedIn() Then Return False End If Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget) + FilenameTarget = GetNormalizedPath(FilenameTarget, True) _logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}") @@ -721,7 +720,7 @@ Public Class Windream Dim oFileIO As WMFileIO Dim oWMStream As WMStream - NewFolder(FilenameTarget, oExtension) + NewFolder(oTargetDrive) 'Indexierungsdialog der Session unterdrücken Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False) @@ -816,10 +815,12 @@ Public Class Windream Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String _logger.Debug("Normalizing Path: [{0}]", Path) Dim oNormalizedPath As String = Path + If pCleanPath = True Then oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path) - _logger.Debug("path after RemoveInvalidCharacters: [{0}]", oNormalizedPath) + _logger.Debug("Path after RemoveInvalidCharacters: [{0}]", oNormalizedPath) End If + Try ' Convert any forward slashes / and double slashes \\ into backslashes \ ' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes @@ -830,7 +831,7 @@ Public Class Windream ' Remove Driveletter, eg. W:\ If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2) - _logger.Debug($"path after replaced ClientDriveLetter: [{oNormalizedPath}]") + _logger.Debug($"Path after replaced ClientDriveLetter: [{oNormalizedPath}]") End If ' Remove Windream Base Path, eg. \\windream\objects\ @@ -845,14 +846,16 @@ Public Class Windream _logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]") oNormalizedPath = oNormalizedPath.Substring(3) End If + If oNormalizedPath.StartsWith("\") = False Then oNormalizedPath = $"\{oNormalizedPath}" End If - _logger.Debug($"oNormalizedPath: [{oNormalizedPath}]") + + _logger.Debug($"NormalizedPath: [{oNormalizedPath}]") Return oNormalizedPath Catch ex As Exception - _logger.Warn($"Unexpected error in GetNormalizedPath - oNormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]") + _logger.Warn($"Unexpected error in GetNormalizedPath - NormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]") Return "" End Try End Function