Просмотр исходного кода

Fixing deck deletion and file manipulation

mbunch_kascope 2 лет назад
Родитель
Сommit
a65f884306
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      Assets/Scripts/ContinuousController.cs

+ 6 - 2
Assets/Scripts/ContinuousController.cs

@@ -365,8 +365,10 @@ public class ContinuousController : MonoBehaviour
         if (!Directory.Exists(filePath))
             return;
 
-        if(File.Exists($"{filePath}/{data.DeckName}_{data.DeckID}.txt"))
-            File.Delete($"{filePath}/{data.DeckName}_{data.DeckID}.txt");
+        if (!File.Exists($"{filePath}/{data.DeckName}_{data.DeckID}.txt"))
+            return;
+
+        File.Delete($"{filePath}/{data.DeckName}_{data.DeckID}.txt");
     }
 
     public void DeleteAllDecks()
@@ -401,6 +403,8 @@ public class ContinuousController : MonoBehaviour
             int KeyCard = int.Parse(sr.ReadLine().Replace("Key Card: ", ""));
             int SortValue = int.Parse(sr.ReadLine().Replace("Sort Index: ", ""));
 
+            sr.Close();
+
             string deck = deckList.Substring(deckList.IndexOf("//"));
             //Debug.Log(deckName);