File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
src/Microsoft.VisualStudio.Editors/ResourceEditor Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -3053,7 +3053,7 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
30533053 With Info
30543054 .Guid = SplitInfo( 0 )
30553055 .ProjectFile = SplitInfo( 1 )
3056- .FilePath = SplitInfo( 2 )
3056+ .FilePath = GetExactPath( SplitInfo(2 ) )
30573057 End With
30583058 Files(i) = Info
30593059 Next
@@ -3069,6 +3069,30 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor
30693069 Return Files
30703070 End Function
30713071
3072+ ' Converts the provided path to use the same capitalization as the file system. Files dragged
3073+ ' from Solution Explorer produce drop data having a lower-case path, which we then write to
3074+ ' in the .resx file. Windows has a case-insensitive file system, but users on other operation
3075+ ' systems (such as Linux) can hit run-time errors when the case doesn't match. This avoids that.
3076+ Private Shared Function GetExactPath(path As String ) As String
3077+ If path Is Nothing OrElse ( Not File.Exists(path) AndAlso Not Directory.Exists(path)) Then
3078+ Return path
3079+ End If
3080+
3081+ Try
3082+ Dim root = System.IO.Path.GetPathRoot(path)
3083+ Dim parts = path.Substring(root.Length).Split(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar)
3084+
3085+ For Each part As String In parts
3086+ root = Directory.EnumerateFileSystemEntries(root, part).First()
3087+ Next
3088+
3089+ Return root
3090+ Catch
3091+ ' If we hit any issues, just return the path unchanged
3092+ Return path
3093+ End Try
3094+ End Function
3095+
30723096# End Region
30733097
30743098# End Region
You can’t perform that action at this time.
0 commit comments