From: gu.martinm@gmail.com Date: Mon, 4 Aug 2014 23:04:06 +0000 (+0200) Subject: WeatherInformation WP8 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=85463dee8fba859528ec90dfc7fb3260c1982b75;p=CSharpForFun%2F.git WeatherInformation WP8 No way of moving temporary file atomically with IsolatedStorageFile Sucks!!! --- 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)