private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e) { // Zip up the iso store MemoryStream original = new MemoryStream(); ICSharpCode.SharpZipLib.Zip.ZipFile file = new ICSharpCode.SharpZipLib.Zip.ZipFile(original); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { foreach (string fname in store.GetFileNames()) { file.BeginUpdate(); CustomStaticDataSource sdsf = new CustomStaticDataSource(); var storefile = store.OpenFile(fname, FileMode.Open, FileAccess.Read); storefile.CopyTo(sdsf._stream); storefile.Close(); sdsf._stream.Position = 0; file.Add(sdsf, fname); file.CommitUpdate(); } file.IsStreamOwner = false; file.Close(); original.Position = 0; // Connect to live API LiveAuthClient auth = new LiveAuthClient("00000000440E7119"); auth.InitializeAsync(); auth.InitializeCompleted += (e1, e2) => { // Show login dialog auth.LoginAsync(new string[] { "wl.skydrive_update" }); auth.LoginCompleted += (e3, e4) => { if (e4.Status == LiveConnectSessionStatus.Connected) { LiveConnectClient client = new LiveConnectClient(e4.Session); // Upload that zip we just made client.UploadAsync("me/skydrive/", "wphfolders.zip", original, OverwriteOption.Overwrite); client.UploadCompleted += (ucSender, ucEvent) => { MessageBox.Show("Uploaded wphfolders.zip to the root of your SkyDrive. Feel free to move it, but put it back if you need to restore!"); }; } else { MessageBox.Show("Not connected to SkyDrive"); } }; }; } }
private void deploybtn_click(object sender, EventArgs e) { save(); string filedata = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<Deployment xmlns=\"http://schemas.microsoft.com/windowsphone/2009/deployment\" AppPlatformVersion=\"7.1\">" + " <App xmlns=\"\" ProductID=\"{" + Guid.NewGuid().ToString() + "}\" Title=\"" + curMenu.name + "\" RuntimeType=\"Silverlight\" Version=\"1.0.0.0\" Genre=\"apps.normal\" Author=\"Jaxbot\" Description=\"Folder\" Publisher=\"WindowsPhoneHacker\">" + " <IconPath IsRelative=\"true\" IsResource=\"false\">ApplicationIcon.png</IconPath>" + " <Capabilities>" + " <Capability Name=\"ID_CAP_GAMERSERVICES\"/>" + " <Capability Name=\"ID_CAP_IDENTITY_DEVICE\"/>" + " <Capability Name=\"ID_CAP_IDENTITY_USER\"/>" + " <Capability Name=\"ID_CAP_LOCATION\"/>" + " <Capability Name=\"ID_CAP_MEDIALIB\"/>" + " <Capability Name=\"ID_CAP_MICROPHONE\"/>" + " <Capability Name=\"ID_CAP_NETWORKING\"/>" + " <Capability Name=\"ID_CAP_PHONEDIALER\"/>" + " <Capability Name=\"ID_CAP_PUSH_NOTIFICATION\"/>" + " <Capability Name=\"ID_CAP_SENSORS\"/>" + " <Capability Name=\"ID_CAP_WEBBROWSERCOMPONENT\"/>" + " <Capability Name=\"ID_CAP_ISV_CAMERA\"/>" + " <Capability Name=\"ID_CAP_CONTACTS\"/>" + " <Capability Name=\"ID_CAP_APPOINTMENTS\"/>" + " </Capabilities>" + " <Tasks>" + " <DefaultTask Name =\"_default\" NavigationPage=\"MainPage.xaml\"/>" + " </Tasks>" + " <Tokens>" + " <PrimaryToken TokenID=\"IndependentFolderToken\" TaskName=\"_default\">" + " <TemplateType5>" + " <BackgroundImageURI IsRelative=\"true\" IsResource=\"false\">Background.png</BackgroundImageURI>" + " <Count>0</Count>" + " <Title>Folder</Title>" + " </TemplateType5>" + " </PrimaryToken>" + " </Tokens>" + " </App>" + "</Deployment>"; MemoryStream original = new MemoryStream(); var res = Application.GetResourceStream(new Uri("IndependentFolder.xap", UriKind.Relative)).Stream; res.CopyTo(original); ICSharpCode.SharpZipLib.Zip.ZipFile file = new ICSharpCode.SharpZipLib.Zip.ZipFile(original); file.BeginUpdate(); MemoryStream filestr = new MemoryStream(System.Text.UTF8Encoding.UTF8.GetBytes(filedata)); CustomStaticDataSource sds = new CustomStaticDataSource(); sds.SetStream(filestr); file.Add(sds, "WMAppManifest.xml"); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { foreach (appentry app in curMenu.apps) { var imgfile = store.OpenFile(app.guid + ".jpg", FileMode.Open, FileAccess.Read); CustomStaticDataSource sdsimg = new CustomStaticDataSource(); imgfile.CopyTo(sdsimg._stream); imgfile.Close(); sdsimg._stream.Position = 0; //sdsimg.SetStream(imgfile); file.Add(sdsimg, "apps/" + app.guid + ".jpg"); file.CommitUpdate(); file.BeginUpdate(); } var menufile = store.OpenFile(curMenu.name + ".folder", FileMode.Open, FileAccess.Read); CustomStaticDataSource sdsmenu = new CustomStaticDataSource(); sdsmenu.SetStream(menufile); file.Add(sdsmenu, "menu.folder"); file.CommitUpdate(); file.IsStreamOwner = false; file.Close(); original.Position = 0; using (var stream = new IsolatedStorageFileStream("package." + curMenu.name + ".zip", FileMode.Create, store)) { original.CopyTo(stream); } } /* * ICSharpCode.SharpZipLib.Zip.ZipOutputStream str = new ICSharpCode.SharpZipLib.Zip.ZipOutputStream(new MemoryStream()); * str.PutNextEntry(new ICSharpCode.SharpZipLib.Zip.ZipEntry("WMAppManifest.xml")); */ //ICSharpCode.SharpZipLib.Zip.zipout //file.Add(str); XapHandler.XapDeployerInterop.Initialize(); XapHandler.XapDeployerInterop.ReadyIsAppInstalled(@"\Applications\Data\5b594f78-a744-4f8a-85d2-f0f55f411832\Data\IsolatedStore\package." + curMenu.name + ".zip"); XapHandler.XapDeployerInterop.FinishInstall(false); }