@@ -138,7 +138,7 @@ public static void DisplaySolutions(List<string> solutionFiles)
138138 }
139139 }
140140
141- public static string GetExportFileNameWithExtension ( string filePath , CoreUtils . ExportFormat format , string ? outputPath = null )
141+ public static string GetExportFileNameWithExtension ( string filePath , ExportFormat format , string ? outputPath = null )
142142 {
143143 string fileName = Path . GetFileName ( filePath ) ;
144144 if ( filePath == null )
@@ -147,15 +147,28 @@ public static string GetExportFileNameWithExtension(string filePath, CoreUtils.E
147147 }
148148 string newExtension = format switch
149149 {
150- CoreUtils . ExportFormat . CSV => ".csv" ,
151- CoreUtils . ExportFormat . JSON => ".json" ,
150+ ExportFormat . CSV => ".csv" ,
151+ ExportFormat . JSON => ".json" ,
152152 _ => throw new ArgumentException ( $ "Unsupported format: { format } ", nameof ( format ) )
153153 } ;
154154
155+ string currentExtension = Path . GetExtension ( filePath ) ;
156+
155157 // If file already has the desired extension, keep it, otherwise change it
156- if ( ! Path . GetExtension ( fileName ) . Equals ( newExtension , StringComparison . OrdinalIgnoreCase ) )
158+ if ( ! currentExtension . Equals ( newExtension , StringComparison . OrdinalIgnoreCase ) )
159+ {
160+ if ( ! string . IsNullOrEmpty ( currentExtension ) )
161+ {
162+ fileName = Path . ChangeExtension ( fileName , newExtension ) ;
163+ }
164+ else
165+ {
166+ fileName = fileName + newExtension ;
167+ }
168+ }
169+ else
157170 {
158- fileName = Path . ChangeExtension ( fileName , newExtension ) ;
171+ fileName = filePath ;
159172 }
160173
161174 // If an output directory is specified, combine the path
0 commit comments