[chronojump] Open CSV has try/catch (maybe is already opened on spreadsheet software)



commit 286a7d6130252f2ae94b2a7a22371a37dc3c559c
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 16 11:31:27 2015 +0200

    Open CSV has try/catch (maybe is already opened on spreadsheet software)

 src/gui/person.cs |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 9a2615e..c0469f9 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -1889,8 +1889,21 @@ public class PersonAddMultipleWindow {
                fc.Filter.AddPattern("*.CSV");
 
                ArrayList array = new ArrayList();
-               if (fc.Run() == (int)ResponseType.Accept) { 
-                       System.IO.FileStream file=System.IO.File.OpenRead(fc.Filename); 
+               if (fc.Run() == (int)ResponseType.Accept) 
+               {
+                       LogB.Warning("Opening CSV...");
+                       System.IO.FileStream file;
+                       try {
+                               file = System.IO.File.OpenRead(fc.Filename); 
+                       } catch {
+                               LogB.Warning("Catched, maybe is used by another program");
+                               new DialogMessage(Constants.MessageTypes.WARNING, 
+                                               Catalog.GetString("Sorry, video cannot be stored.") + "\n\n" +
+                                               Catalog.GetString("Maybe this file is opened by an 
SpreadSheet software like Excel. Please, close that program.")
+                                               );
+                               fc.Destroy();
+                               return;
+                       }
 
                        List<string> columns = new List<string>();
                        using (var reader = new CsvFileReader(fc.Filename))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]