From 85463dee8fba859528ec90dfc7fb3260c1982b75 Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Tue, 5 Aug 2014 01:04:06 +0200 Subject: [PATCH] WeatherInformation WP8 No way of moving temporary file atomically with IsolatedStorageFile Sucks!!! --- .../WeatherInformation/WeatherInformation/App.xaml.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs index 50952be..53ccf9b 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/App.xaml.cs @@ -239,6 +239,7 @@ namespace WeatherInformation }; } + // no way of moving temporary file atomically with IsolatedStorageFile. LINUX OWNS MICROSOFT. private void SaveDataToIsolatedStorage(string fileName, string value) { string pathToTemporaryFile = CreateTemporaryFile(fileName); @@ -247,7 +248,14 @@ namespace WeatherInformation using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) { - // Hopefully NTFS rename atomic... No too much information :/ + // NO FUCKING WAY, MoveFile throws exception if destination file exists!!!! + // And documentation doesn't say anything... ROFL + // Linux OWNS Microsoft... + // If there are corrupted files do not blame me.... Unbelievable.... + if (isoStore.FileExists(fileName)) + { + isoStore.DeleteFile(fileName); + } isoStore.MoveFile(pathToTemporaryFile, fileName); } } @@ -259,7 +267,7 @@ namespace WeatherInformation isoStore.CreateDirectory("tmp"); } - return String.Concat("tmp/", fileName); + return Path.Combine("tmp", fileName); } private void SaveDataToTemporaryFile(string pathToTemporaryFile, string value) -- 2.1.4