Skip to content

Commit

Permalink
App bundle is not removed on relaunch
Browse files Browse the repository at this point in the history
  • Loading branch information
purplecabbage committed Nov 22, 2011
1 parent a5e64a3 commit 35329f3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions framework/PGView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public partial class PGView : UserControl
private bool IsBrowserInitialized = false;
private bool OverrideBackButton = false;

private static string AppRoot = "app\\";


/// <summary>
/// Handles native api calls
Expand Down Expand Up @@ -85,7 +87,7 @@ public Uri StartPageUri
if (_startPageUri == null)
{
// default
return new Uri("www/index.html", UriKind.Relative);
return new Uri( AppRoot + "www/index.html", UriKind.Relative);
}
else
{
Expand Down Expand Up @@ -205,10 +207,12 @@ void GapBrowser_Loaded(object sender, RoutedEventArgs e)
}

Debug.WriteLine("Updating IsolatedStorage for APP:DeviceID :: " + deviceUUID);

// always overwrite user-iso-store if we are in debug mode.
#if DEBUG
appStorage.Remove();
#endif
//if (appStorage.DirectoryExists("app"))
//{
// appStorage.DeleteDirectory("app");
//}

IsolatedStorageFileStream file = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Create, FileAccess.Write, appStorage);
using (StreamWriter writeFile = new StreamWriter(file))
Expand All @@ -231,7 +235,7 @@ void GapBrowser_Loaded(object sender, RoutedEventArgs e)
var files = from results in document.Descendants("FilePath")
select new
{
path = (string)results.Attribute("Value")
path = (string)results.Attribute("Value")
};
StreamResourceInfo fileResourceStreamInfo;

Expand All @@ -248,13 +252,13 @@ void GapBrowser_Loaded(object sender, RoutedEventArgs e)
{
byte[] data = br.ReadBytes((int)fileResourceStreamInfo.Stream.Length);

string strBaseDir = file.path.Substring(0, file.path.LastIndexOf(System.IO.Path.DirectorySeparatorChar));
string strBaseDir = AppRoot + file.path.Substring(0, file.path.LastIndexOf(System.IO.Path.DirectorySeparatorChar));
appStorage.CreateDirectory(strBaseDir);

// This will truncate/overwrite an existing file, or
using (IsolatedStorageFileStream outFile = appStorage.OpenFile(file.path, FileMode.Create))
using (IsolatedStorageFileStream outFile = appStorage.OpenFile(AppRoot + file.path, FileMode.Create))
{
Debug.WriteLine("Writing data for " + file.path + " and length = " + data.Length);
Debug.WriteLine("Writing data for " + AppRoot + file.path + " and length = " + data.Length);
using (var writer = new BinaryWriter(outFile))
{
writer.Write(data);
Expand Down

0 comments on commit 35329f3

Please sign in to comment.