@@ -277,7 +277,15 @@ public static void GeneratePythonPanda(CsvDefinition csvdef)
277277 IScintillaGateway editor = new ScintillaGateway ( PluginBase . GetCurrentScintilla ( ) ) ;
278278
279279 // Python requires forward slash for filepaths
280- string FILE_PATH = Path . GetDirectoryName ( notepad . GetCurrentFilePath ( ) ) ;
280+ string FILE_PATH = "" ;
281+ try
282+ {
283+ FILE_PATH = Path . GetDirectoryName ( notepad . GetCurrentFilePath ( ) ) ;
284+ }
285+ catch ( Exception ex )
286+ {
287+ // Path.GetDirectoryName will crash on long filepath (>260 chars)
288+ }
281289 string FILE_NAME = notepad . GetCurrentFilePath ( ) ;
282290
283291 FILE_PATH = FILE_PATH . Replace ( "\\ " , "\\ \\ " ) ;
@@ -565,7 +573,15 @@ public static void GenerateRScript(CsvDefinition csvdef)
565573 IScintillaGateway editor = new ScintillaGateway ( PluginBase . GetCurrentScintilla ( ) ) ;
566574
567575 // R-studio requires forward slash for filepaths
568- string FILE_PATH = Path . GetDirectoryName ( notepad . GetCurrentFilePath ( ) ) ;
576+ string FILE_PATH = "" ;
577+ try
578+ {
579+ FILE_PATH = Path . GetDirectoryName ( notepad . GetCurrentFilePath ( ) ) ;
580+ }
581+ catch ( Exception ex )
582+ {
583+ // Path.GetDirectoryName will crash on long filepath (>260 chars)
584+ }
569585 string FILE_NAME = notepad . GetCurrentFilePath ( ) ;
570586
571587 FILE_PATH = FILE_PATH . Replace ( "\\ " , "/" ) ;
@@ -808,7 +824,15 @@ public static void GeneratePowerShell(CsvDefinition csvdef)
808824 IScintillaGateway editor = new ScintillaGateway ( PluginBase . GetCurrentScintilla ( ) ) ;
809825
810826 // Python requires forward slash for filepaths
811- string FILE_PATH = Path . GetDirectoryName ( notepad . GetCurrentFilePath ( ) ) . TrimEnd ( Path . DirectorySeparatorChar ) + Path . DirectorySeparatorChar ;
827+ string FILE_PATH = "" ;
828+ try
829+ {
830+ FILE_PATH = Path . GetDirectoryName ( notepad . GetCurrentFilePath ( ) ) . TrimEnd ( Path . DirectorySeparatorChar ) + Path . DirectorySeparatorChar ;
831+ }
832+ catch ( Exception ex )
833+ {
834+ // Path.GetDirectoryName will crash on long filepath (>260 chars)
835+ }
812836 string FILE_NAME = Path . GetFileName ( notepad . GetCurrentFilePath ( ) ) ;
813837
814838 StringBuilder ps1 = new StringBuilder ( ) ;
0 commit comments