path2Long in MoveRename
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1092,7 +1092,10 @@ Public Class ClassNIWindream
|
||||
|
||||
targetpath = targetpath.Replace("\\", "\")
|
||||
Const WMEntityDocument = 1
|
||||
|
||||
If targetpath.Length >= 256 Then
|
||||
_Logger.Info($"⚠️ WARNING: Error in NEW_MOVE_FILE - targetpath is too long [{targetpath}]")
|
||||
Return False
|
||||
End If
|
||||
_Logger.Debug($"getting WMObject for: {sourcepath}")
|
||||
Try
|
||||
oWMFile = oWMSession.GetWMObjectByPath(WMEntityDocument, sourcepath)
|
||||
@@ -1115,8 +1118,9 @@ Public Class ClassNIWindream
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Warn($"Error in NEW_MOVE_FILE pFileName: [{pFileName}] - targetpath: [{targetpath}]")
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn($"Error in NEW_MOVE_FILE pFileName [{pFileName}] - [{targetpath}]")
|
||||
|
||||
If Not IsNothing(oWMFile) Then
|
||||
oWMFile.unlock()
|
||||
End If
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.10.4.0")>
|
||||
<Assembly: AssemblyVersion("2.11.11.0")>
|
||||
<Assembly: AssemblyFileVersion("2.9.9.0")>
|
||||
|
||||
@@ -1783,7 +1783,8 @@ Public Class frmNIHauptseite
|
||||
End Sub
|
||||
Private Function FolderForIndex(oDynamicFolder As String, myWMDocument As WMObject) As String
|
||||
Try
|
||||
_Logger.Debug("Dynamic folder before cleaning: " & oDynamicFolder)
|
||||
_Logger.Debug($"FolderForIndex -> Dynamic folder before cleaning: {oDynamicFolder}")
|
||||
|
||||
' 1. Platzhalter durch tatsächliche Werte ersetzen
|
||||
Dim resolvedFolder As String = ResolveFolderPlaceholders(oDynamicFolder, myWMDocument)
|
||||
If String.IsNullOrEmpty(resolvedFolder) Then
|
||||
@@ -1795,8 +1796,14 @@ Public Class frmNIHauptseite
|
||||
Dim pathWithoutDrive As String = resolvedFolder
|
||||
|
||||
If resolvedFolder.Length >= 2 AndAlso resolvedFolder.Chars(1) = ":"c Then
|
||||
driveLetter = resolvedFolder.Substring(0, 2) ' z.B. "W:"
|
||||
pathWithoutDrive = resolvedFolder.Substring(2) ' Rest des Pfads
|
||||
' Wenn Backslash vorhanden (W:\), 3 Zeichen nehmen, sonst 2 (W:) und Backslash anfügen
|
||||
If resolvedFolder.Length >= 3 AndAlso resolvedFolder.Chars(2) = "\"c Then
|
||||
driveLetter = resolvedFolder.Substring(0, 3) ' z.B. "W:\"
|
||||
pathWithoutDrive = resolvedFolder.Substring(3)
|
||||
Else
|
||||
driveLetter = resolvedFolder.Substring(0, 2) & "\" ' z.B. "W:" -> "W:\"
|
||||
pathWithoutDrive = resolvedFolder.Substring(2)
|
||||
End If
|
||||
End If
|
||||
|
||||
' 3. Ungültige Zeichen aus jedem Ordnernamen entfernen
|
||||
@@ -1804,9 +1811,15 @@ Public Class frmNIHauptseite
|
||||
|
||||
' 4. Vollständigen Pfad zusammensetzen
|
||||
Dim cleanedFolder As String = driveLetter & pathWithoutDrive
|
||||
_Logger.Debug("Dynamic folder after cleaning: " & cleanedFolder)
|
||||
_Logger.Debug($"FolderForIndex -> Dynamic folder after cleaning: {cleanedFolder}")
|
||||
|
||||
' 5. Ordner erstellen falls nicht vorhanden
|
||||
' 5. Pfadlängen-Prüfung (Windows MAX_PATH = 260, aber besser bei 256 warnen)
|
||||
If cleanedFolder.Length >= 256 Then
|
||||
_Logger.Info($"⚠️ WARNING: Folder path is too long ({cleanedFolder.Length} characters): {cleanedFolder}")
|
||||
Return "Path2Long"
|
||||
End If
|
||||
|
||||
' 6. Ordner erstellen falls nicht vorhanden
|
||||
If Not Directory.Exists(cleanedFolder) Then
|
||||
Directory.CreateDirectory(cleanedFolder)
|
||||
_Logger.Debug($"Folder '{cleanedFolder}' has been created...")
|
||||
@@ -1933,7 +1946,26 @@ Public Class frmNIHauptseite
|
||||
|
||||
Dim rgPattern As String = My.Settings.REGEX_INVALID_PATH
|
||||
Dim objRegEx As New Regex(rgPattern)
|
||||
Dim pathSegments As String() = path.Split("\"c)
|
||||
|
||||
' UNC-Präfix oder Laufwerksbuchstaben merken
|
||||
Dim prefix As String = String.Empty
|
||||
Dim workingPath As String = path
|
||||
|
||||
' Prüfen ob UNC-Pfad (beginnt mit \\)
|
||||
If path.StartsWith("\\") Then
|
||||
prefix = "\\"
|
||||
workingPath = path.Substring(2)
|
||||
' Prüfen ob Laufwerksbuchstabe (z.B. W:\)
|
||||
ElseIf path.Length >= 3 AndAlso path.Chars(1) = ":"c AndAlso path.Chars(2) = "\"c Then
|
||||
prefix = path.Substring(0, 3) ' z.B. "W:\"
|
||||
workingPath = path.Substring(3)
|
||||
ElseIf path.Length >= 2 AndAlso path.Chars(1) = ":"c Then
|
||||
prefix = path.Substring(0, 2) & "\" ' z.B. "W:" wird zu "W:\"
|
||||
workingPath = path.Substring(2)
|
||||
End If
|
||||
|
||||
' Pfad in Segmente aufteilen und bereinigen
|
||||
Dim pathSegments As String() = workingPath.Split("\"c)
|
||||
Dim cleanedSegments As New List(Of String)
|
||||
|
||||
For Each segment As String In pathSegments
|
||||
@@ -1950,7 +1982,8 @@ Public Class frmNIHauptseite
|
||||
cleanedSegments.Add(cleanedSegment)
|
||||
Next
|
||||
|
||||
Return String.Join("\", cleanedSegments)
|
||||
' Pfad mit Präfix zusammensetzen
|
||||
Return prefix & String.Join("\", cleanedSegments)
|
||||
End Function
|
||||
|
||||
|
||||
@@ -1978,6 +2011,9 @@ Public Class frmNIHauptseite
|
||||
End If
|
||||
If oTargetpath = "" Then
|
||||
Return True
|
||||
ElseIf oTargetpath = "Path2Long" Then
|
||||
_Logger.Info($"⚠️ WARNING: Targetpath is too long for document [{myWMDocument.aName}] - Move and Rename skipped!")
|
||||
Return True
|
||||
End If
|
||||
|
||||
'schonmal den gesamten Pfad laden - OHNE Extension zuerst
|
||||
|
||||
Reference in New Issue
Block a user