예제 #1
0
        //-----------------------------------------------------------------------------------------------------------------



        //Prüfen ob Return gedrückt wurde
        //-----------------------------------------------------------------------------------------------------------------
        private void TBFolderName_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            //Prüfen ob Name vorhanden
            if (TBFolderName.Text.Length > 0)
            {
                //Prüfen ob Return gedrückt wurde
                string tempkey = Convert.ToString(e.Key);
                if (tempkey == "Enter")
                {
                    //";" Zeichen herauslöschen
                    TBFolderName.Text = Regex.Replace(TBFolderName.Text, ";", "");
                    //Prüfen ob noch Zeichen vorhanden
                    if (TBFolderName.Text.Length > 0)
                    {
                        //Prüfen ob leere Eingabe und zurücksetzen
                        bool temp = Regex.IsMatch(TBFolderName.Text, @"^[a-zA-Z0-9 ]+$");
                        temp = true;
                        if (temp == false)
                        {
                            MessageBox.Show(Lockscreen_Swap.AppResx.ErrorName);
                            TBFolderName.Text = "";
                        }
                        else
                        {
                            //Prüfen ob Ordner bereits besteht
                            if (!file.FileExists("/Profile/" + TBFolderName.Text + ".txt"))
                            {
                                try
                                {
                                    //Neue Ordner Datei erstellen
                                    file.CopyFile("/Settings/Settings.txt", "/Profile/" + TBFolderName.Text + ".txt");
                                    //Zurück gehen
                                    NavigationService.GoBack();
                                }
                                catch
                                {
                                    MessageBox.Show(Lockscreen_Swap.AppResx.ErrorName);
                                    TBFolderName.Text = "";
                                }
                            }
                            //Wenn Ordner bereits besteht
                            else
                            {
                                MessageBox.Show(Lockscreen_Swap.AppResx.ErrorName);
                                TBFolderName.Text = "";
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(Lockscreen_Swap.AppResx.ErrorEnterName);
                        TBFolderName.Text = "";
                    }

                    //Focus zurücksetzen
                    //Focus();
                }
            }
        }
예제 #2
0
        //---------------------------------------------------------------------------------------------------------



        //Button Style speichern
        //---------------------------------------------------------------------------------------------------------
        private void BtnSaveImagesClick(object sender, RoutedEventArgs e)
        {
            try
            {
                //Bilder in neuen Style kopieren
                for (int i = 1; i <= 4; i++)
                {
                    if (file.FileExists("StylesImages/" + OnlineDirectory + "." + i + ".png"))
                    {
                        file.DeleteFile("StylesImages/" + OnlineDirectory + "." + i + ".png");
                    }
                    file.CopyFile("TempStyles/" + i + ".png", "StylesImages/" + OnlineDirectory + "." + i + ".png");
                }
                //Style Datei kopieren
                if (file.FileExists("Styles/" + OnlineDirectory + ".txt"))
                {
                    file.DeleteFile("Styles/" + OnlineDirectory + ".txt");
                }
                file.CopyFile("TempStyles/txt.txt", "Styles/" + OnlineDirectory + ".txt");

                //InastalledStyles ändern und speichern
                InstalledStyles += OnlineDirectory + ".txt;";
                filestream       = file.CreateFile("Settings/InstalledStyles.txt");
                sw = new StreamWriter(filestream);
                sw.WriteLine(InstalledStyles);
                sw.Flush();
                filestream.Close();

                //Bilderliste neu erstellen
                ActionIfSelect = false;
                CreateImages();
                ActionIfSelect = true;
                SelectImages();

                //Online Styles neu erstellen
                if (Source != "")
                {
                    CreateOnlineImages();
                }

                //Menü verbergen
                SPSaveImages.Visibility = System.Windows.Visibility.Collapsed;
                GRImagesOnline.Margin   = new Thickness(-600, 0, 0, 0);
                MenuOpen = false;
            }
            catch
            {
                MessageBox.Show(Lockscreen_Swap.AppResx.Z04_Exists);
            }
        }
예제 #3
0
        void BTR_Download_TransferStatusChanged(object sender, BackgroundTransferEventArgs e)
        {
            if (e.Request.TransferStatus == TransferStatus.Completed)
            {
                Downloading = false;
                if (e.Request.StatusCode == 200)
                {
                    using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        if (iso.FileExists(DOWNLOAD_LOCATION))
                        {
                            iso.CopyFile(DOWNLOAD_LOCATION, "/cars.sdf", true);
                        }
                    }
                    string DBConnectionString = "Data Source=isostore:/cars.sdf";
                    App.ViewModel.Database.Dispose();

                    /*
                     * App.ViewModel.Database.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues,App.ViewModel.Database.carInfo);
                     * App.ViewModel.Database.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, App.ViewModel.Database.fuelInfo);
                     * App.ViewModel.Database.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, App.ViewModel.Database.maintInfo);
                     * App.ViewModel.Database.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, App.ViewModel.Database.settingsInfo);
                     */
                    App.ViewModel = new Data(DBConnectionString);
                }
                BackgroundTransferService.Remove(e.Request);
            }
            Debug.WriteLine(e.Request.TransferStatus);
            Debug.WriteLine("downloaded-" + e.Request.BytesReceived);
        }
예제 #4
0
        public void Upload(AsyncCallback UploadCallback, AsyncCallback uploadProgressCallback)
        {
            string upload_uri = FILEPICKER_BASEURL + "/api/store/S3?key=" + FILEPICKER_APIKEY;

            BTR = new BackgroundTransferRequest(new Uri(upload_uri));
            BTR.TransferStatusChanged   += BTR_TransferStatusChanged;
            BTR.TransferProgressChanged += BTR_TransferProgressChanged;
            BTR.Method = "POST";

            using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!iso.DirectoryExists(TRANSFER_FOLDER))
                {
                    iso.CreateDirectory(TRANSFER_FOLDER);
                }
                iso.CopyFile("/cars.sdf", TRANSFER_FOLDER + "/cars.sdf", true);
            }
            BTR.DownloadLocation = new Uri(SAVE_RESPONSE_LOCATION, UriKind.Relative);
            BTR.UploadLocation   = new Uri(TRANSFER_FOLDER + "/cars.sdf", UriKind.Relative);
            if (!Uploading)
            {
                Uploading = true;
                foreach (BackgroundTransferRequest req in BackgroundTransferService.Requests)
                {
                    if (req.UploadLocation == BTR.UploadLocation)
                    {
                        BackgroundTransferService.Remove(req);
                    }
                }
                BackgroundTransferService.Add(BTR);
                _uploadCallback = UploadCallback;
                _uplaodProgressChangeCallback = uploadProgressCallback;
            }
        }
예제 #5
0
        // ---------------------------------------------------------------------------------------------------



        // Ordner allen Dateien und Unterorden löschen
        // ---------------------------------------------------------------------------------------------------
        public static void copyIsoStoreToIsoStore(string pathSource, string pathTarget)
        {
            // Ordner erstellen // pathTarget
            if (!file.DirectoryExists(pathTarget))
            {
                file.CreateDirectory(pathTarget);
            }


            // Ordner und Dateien laden // pathSource
            string[] files   = file.GetFileNames(pathSource);
            string[] folders = file.GetDirectoryNames(pathSource);


            // Dateien kopieren
            for (int i = 0; i < files.Count(); i++)
            {
                if (file.FileExists(pathSource + files[i]))
                {
                    if (file.DirectoryExists(pathTarget + "/"))
                    {
                    }
                }
                file.CopyFile(pathSource + files[i], pathTarget + "/" + files[i]);
            }


            // Ordner durchlaufen und kopieren
            for (int i = 0; i < folders.Count(); i++)
            {
                copyIsoStoreToIsoStore(pathSource + folders[i] + "/", pathTarget + "/" + folders[i]);
            }
        }
예제 #6
0
파일: File.cs 프로젝트: trieu/phonegap
        private void CopyDirectory(string sourceDir, string destDir, IsolatedStorageFile isoFile)
        {
            string path = File.AddSlashToDirectory(sourceDir);

            if (!isoFile.DirectoryExists(destDir))
            {
                isoFile.CreateDirectory(destDir);
            }
            destDir = File.AddSlashToDirectory(destDir);
            string[] files = isoFile.GetFileNames(path + "*");
            if (files.Length > 0)
            {
                foreach (string file in files)
                {
                    isoFile.CopyFile(path + file, destDir + file);
                }
            }
            string[] dirs = isoFile.GetDirectoryNames(path + "*");
            if (dirs.Length > 0)
            {
                foreach (string dir in dirs)
                {
                    CopyDirectory(path + dir, destDir + dir, isoFile);
                }
            }
        }
예제 #7
0
        public static async Task SetImage(Uri uri)
        {
            string fileName  = uri.Segments[uri.Segments.Length - 1];
            string imageName = BackgroundRoot + fileName;
            string iconName  = IconRoot + fileName;

            using (IsolatedStorageFile storageFolder = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!storageFolder.DirectoryExists(BackgroundRoot))
                {
                    storageFolder.CreateDirectory(BackgroundRoot);
                }

                if (!storageFolder.FileExists(imageName))
                {
                    using (IsolatedStorageFileStream stream = storageFolder.CreateFile(imageName))
                    {
                        HttpClient client      = new HttpClient();
                        byte[]     flikrResult = await client.GetByteArrayAsync(uri);

                        await stream.WriteAsync(flikrResult, 0, flikrResult.Length);
                    }
                }
                storageFolder.CopyFile(imageName, iconName);
            }
            //Set the lockscreen
            await SetLockScreen(fileName);
        }
예제 #8
0
        public void RestoreDatabase(string tmpPathDatabase)
        {
            dellAppDB.Dispose();
            //check downloaded database for version

            string tmpDBConnectionString = "Data Source=isostore:/" + tmpPathDatabase;

            // Create the database if it does not exist.
            using (DBClass tmpDB = new DBClass(tmpDBConnectionString))
            {
                if (tmpDB.DatabaseExists() == true)
                {
                    DatabaseSchemaUpdater dbNewUpdater = tmpDB.CreateDatabaseSchemaUpdater();

                    if (dbNewUpdater.DatabaseSchemaVersion < App.DB_VERSION)
                    {
                    }

                    // version are equal -> replace database files
                    tmpDB.Dispose();
                    IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
                    iso.CopyFile(tmpPathDatabase, AppResources.DatabaseName + ".sdf", true);
                    iso.DeleteFile(tmpPathDatabase);
                }
                else
                {
                    MessageBox.Show("Restore failed because the downloaded file is no database for this app.");
                }
            }

            this.ConnectDB();
        }
예제 #9
0
        public static void Save <ItemType>(this ItemType obj, string path)
        {
            using (IsolatedStorageFile store = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null))
            {
                var writePath = GetSaveFileName(store, path);
                using (var fs = store.OpenFile(writePath, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    try
                    {
                        var ser = new BinaryFormatter();
                        ser.Serialize(fs, obj);

                        if (writePath != path)
                        {
                            store.CopyFile(writePath, path, true);
                        }
                        if (store.FileExists(path + "~"))
                        {
                            store.DeleteFile(path + "~");
                        }
                    }
                    catch { }
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Copies a source directory to specified destination directory.
        /// </summary>
        /// <param name="src">Path of the source directory</param>
        /// <param name="dest">Path of the destination directory</param>
        internal static void CopyDirectory(string src, string dest)
        {
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!storage.DirectoryExists(dest))
                {
                    storage.CreateDirectory(dest);
                }

                // Copy all files.
                string[] files = storage.GetFileNames(src + "\\*.*");
                foreach (string file in files)
                {
                    string srcfile  = Path.Combine(src, file);
                    string destfile = Path.Combine(dest, file);
                    // Delete file if exists
                    if (storage.FileExists(destfile))
                    {
                        storage.DeleteFile(destfile);
                    }
                    storage.CopyFile(srcfile, destfile);
                }

                // Process subdirectories.
                string[] dirs = storage.GetDirectoryNames(src + "\\*");
                foreach (string dir in dirs)
                {
                    string destinationDir = Path.Combine(dest, dir);
                    string srcDir         = Path.Combine(src, dir);
                    CopyDirectory(srcDir, destinationDir);
                }
            }
        }
        /// <summary>
        /// Resaves video clip from temporary directory to persistent
        /// </summary>
        private VideoResult SaveVideoClip()
        {
            try
            {
                using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (string.IsNullOrEmpty(filePath) || (!isoFile.FileExists(filePath)))
                    {
                        return(new VideoResult(TaskResult.Cancel));
                    }

                    string fileName = String.Format(FileNameFormat, Guid.NewGuid().ToString());
                    string newPath  = Path.Combine("/" + LocalFolderName + "/", fileName);
                    isoFile.CopyFile(filePath, newPath);
                    isoFile.DeleteFile(filePath);

                    memoryStream = new MemoryStream();
                    using (IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(newPath, FileMode.Open, isoFile))
                    {
                        fileStream.CopyTo(memoryStream);
                    }

                    VideoResult result = new VideoResult(TaskResult.OK);
                    result.VideoFileName = newPath;
                    result.VideoFile     = this.memoryStream;
                    result.VideoFile.Seek(0, SeekOrigin.Begin);
                    return(result);
                }
            }
            catch (Exception)
            {
                return(new VideoResult(TaskResult.None));
            }
        }
예제 #12
0
        public async Task BackupLocalDatabase()
        {
            string toUploadDatabaseName = "toUploadDatabase.sdf";

            //release all resources from DB
            App.AppViewModel.DisposeCurrentDB();
            // Obtain the virtual store for the application.
            IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();

            iso.CopyFile(AppResources.DatabaseName + ".sdf", toUploadDatabaseName, true);
            App.AppViewModel.ConnectDB();

            LiveConnectClient liveClient = new LiveConnectClient(oneDriveAuthClient.Session);

            try
            {
                using (Stream uploadStream = iso.OpenFile(toUploadDatabaseName, FileMode.Open))
                {
                    if (uploadStream != null)
                    {
                        LiveOperationResult uploadResult = await liveClient.UploadAsync(oneDriveFolderId, databaseBackupname + ".sdf", uploadStream, OverwriteOption.Overwrite);

                        MessageBox.Show("Upload successful.");
                    }
                }
                iso.DeleteFile(toUploadDatabaseName);
                await getFileFromBackupFolderAsync();
            }
            catch (LiveConnectException ex)
            {
                App.AppViewModel.SendExceptionReport(ex);
            }
        }
예제 #13
0
        private async void Upload_Btn_Click(object sender, EventArgs e)
        {
            if (ListPhotos.SelectedItems.Count > 0)
            {
                StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("shared", CreationCollisionOption.OpenIfExists);

                folder = await folder.CreateFolderAsync("transfers", CreationCollisionOption.OpenIfExists);

                using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    for (int i = 0; i < ListPhotos.SelectedItems.Count; i++)
                    {
                        var entry = ListPhotos.SelectedItems[i] as Entry;

                        // copy to shared/transfers folder
                        if (isoStore.FileExists(entry.ImgSrc))
                        {
                            try
                            {
                                isoStore.CopyFile(entry.ImgSrc, "/shared/transfers/" + entry.ImgSrc);
                                LiveOperationResult res = await App.ViewModelData.LiveClient.BackgroundUploadAsync("me/skydrive",
                                                                                                                   new Uri("/shared/transfers/" + entry.ImgSrc, UriKind.Relative), OverwriteOption.Rename);
                            }
                            catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); }
                        }
                    }
                }
            }
        }
예제 #14
0
 public override void Copy(string sourceFileName, string destinationFileName)
 {
     if (!sourceFileName.IsRemotePath() && _store.FileExists(sourceFileName))
     {
         _store.CopyFile(sourceFileName, destinationFileName);
     }
     else if (File.Exists(sourceFileName))
     {
         using (var stream = File.Open(sourceFileName, FileMode.Open))
             using (var isostream = _store.OpenFile(destinationFileName, FileMode.OpenOrCreate))
             {
                 stream.CopyTo(isostream);
                 isostream.Flush();
             }
     }
 }
예제 #15
0
        private void CacheForMerge(IsolatedStorageFile appStorage)
        {
            if (appStorage.FileExists("MergeCache"))
            {
                appStorage.DeleteFile("MergeCache");
            }

            appStorage.CopyFile(GetFileName(), "MergeCache");
        }
예제 #16
0
        private void SetData()
        {
            JObject content = (JObject)Message.Content;
            string  internalFileReference = (string)content[InternalFileReferenceKey];

            if (internalFileReference != null)
            {
                requestPath = FileReference.Parse(internalFileReference).Path;

                return;
            }

            JToken data = content[DataKey];

            if (data == null || data.Type == JTokenType.Null)
            {
                return;
            }

            if (uploadAsFile)
            {
                string sourcePath = (string)data;

                if (sourcePath.StartsWith("file://"))
                {
                    sourcePath = (new Uri(sourcePath)).AbsolutePath;
                }

                requestPath = contentManager.CreateUniqueFilename(Path.GetExtension(sourcePath));

                using (IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    userStore.CopyFile(sourcePath, requestPath);
                }

                Message.Content[InternalFileReferenceKey] = (new FileReference(requestPath, null)).ToString();
                MessageStore.Outbox.Update(Message);
            }
            else
            {
                string contentType = GetHeader("content-type");

                if (contentType != null && contentType == "application/json")
                {
                    requestData = Encoding.UTF8.GetBytes((string)data.ToString());
                }
                else if (contentType != null && contentType.StartsWith("text/"))
                {
                    requestData = Encoding.UTF8.GetBytes((string)data);
                }
                else
                {
                    requestData = Convert.FromBase64String((string)data);
                }
            }
        }
예제 #17
0
        //-----------------------------------------------------------------------------------------------------------------



        //Prüfen ob Return gedrückt wurde
        //-----------------------------------------------------------------------------------------------------------------
        private void TBStyleName_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            //Prüfen ob Return gedrückt wurde
            string tempkey = Convert.ToString(e.Key);

            if (tempkey == "Enter")
            {
                if (TBStyleName.Text.Length > 0)
                {
                    try
                    {
                        string NameToCreate = TBStyleName.Text;
                        NameToCreate = NameToCreate.Trim();
                        file.CreateDirectory("Sounds/ " + NameToCreate);
                        file.CopyFile("Sounds/" + OldName + "/BatteryLow.mp3", "Sounds/ " + NameToCreate + "/BatteryLow.mp3");
                        file.CopyFile("Sounds/" + OldName + "/BatteryIsCharging.mp3", "Sounds/ " + NameToCreate + "/BatteryIsCharging.mp3");
                        file.CopyFile("Sounds/" + OldName + "/BatteryFullyCharged.mp3", "Sounds/ " + NameToCreate + "/BatteryFullyCharged.mp3");
                        NavigationService.GoBack();
                    }
                    catch
                    {
                        MessageBox.Show(Lockscreen_Swap.AppResx.Z01_InUse);
                        TBStyleName.Text = StyleName;
                    }
                }
            }
        }
        private void MenuItemPin_Click(object sender, RoutedEventArgs e)
        {
            PodcastSubscriptionModel subscriptionToPin = (sender as MenuItem).DataContext as PodcastSubscriptionModel;

            // Copy the logo file to tile's shared location.
            String tileImageLocation = "Shared/ShellContent/" + subscriptionToPin.PodcastLogoLocalLocation.Split('/')[1];

            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (myIsolatedStorage.FileExists(subscriptionToPin.PodcastLogoLocalLocation) == false)
                {
                    Debug.WriteLine("Podcast logo not found. Cannot pin.");
                    App.showNotificationToast("Podcast logo not found. Cannot pin.");
                    return;
                }

                if (myIsolatedStorage.FileExists(tileImageLocation) == false)
                {
                    myIsolatedStorage.CopyFile(subscriptionToPin.PodcastLogoLocalLocation,
                                               tileImageLocation);
                }
            }

            // Setup data for the live tile.
            StandardTileData tileData = new StandardTileData();

            tileData.BackgroundImage = new Uri("isostore:/" + tileImageLocation, UriKind.Absolute);
            tileData.Title           = subscriptionToPin.PodcastName;

            IsolatedStorageSettings settings    = IsolatedStorageSettings.ApplicationSettings;
            String subscriptionLatestEpisodeKey = App.LSKEY_BG_SUBSCRIPTION_LATEST_EPISODE + subscriptionToPin.PodcastId;

            if (settings.Contains(subscriptionLatestEpisodeKey) == false)
            {
                settings.Add(subscriptionLatestEpisodeKey, ""); // Create empty key so we know the subscription is pinned.
            }

            subscriptionToPin.EpisodesManager.updatePinnedInformation();

            try
            {
                Uri tileUri = new Uri(string.Format("/Views/PodcastEpisodes.xaml?podcastId={0}&forceUpdate=true", subscriptionToPin.PodcastId), UriKind.Relative);
                Debug.WriteLine(string.Format("Pinning to start: Image: {0} Title: {1} Navigation uri: {2}", tileData.BackgroundImage, tileData.Title, tileUri));
                ShellTile.Create(tileUri, tileData);
            }
            catch (InvalidOperationException)
            {
                Debug.WriteLine("Could not pin to start screen. The subscription is already pinned.");
            }
        }
예제 #19
0
 private void copyImageToShellContent(String filename, String uniquekey)
 {
     try
     {
         using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
         {
             if (!doesFileExist("/Shared/ShellContent/wptraktbg" + uniquekey + ".jpg") && doesFileExist(filename))
             {
                 store.CopyFile(filename, "/Shared/ShellContent/wptraktbg" + uniquekey + ".jpg");
             }
         }
     }
     catch (IsolatedStorageException) { }
 }
예제 #20
0
        /// <summary>
        /// Uploader notre base de données sur OneDrive
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public async static Task <int> ExportDB(CancellationToken ct, Progress <LiveOperationProgress> uploadProgress)
        {
            int log = 0;

            if (LiveClient == null)
            {
                log = await LogClient();
            }

            // Prepare for download, make sure there are no previous requests
            var reqList = BackgroundTransferService.Requests.ToList();

            foreach (var req in reqList)
            {
                if (req.UploadLocation.Equals(new Uri(@"\shared\transfers\" + AppResources.DBFileName, UriKind.Relative)) ||
                    req.UploadLocation.Equals(new Uri(@"\shared\transfers\" + AppResources.DBFileName + ".json", UriKind.Relative)))
                {
                    BackgroundTransferService.Remove(BackgroundTransferService.Find(req.RequestId));
                }
            }

            IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();

            iso.CopyFile(AppResources.DBFileName, "/shared/transfers/" + AppResources.DBFileName, true);

            //  create a folder
            string folderID = await GetFolderID("checkmapp");

            if (string.IsNullOrEmpty(folderID))
            {
                //  return error
                return(0);
            }

            //  upload local file to OneDrive
            LiveClient.BackgroundTransferPreferences = BackgroundTransferPreferences.AllowCellularAndBattery;
            try
            {
                await LiveClient.BackgroundUploadAsync(folderID, new Uri("/shared/transfers/" + AppResources.DBFileName, UriKind.RelativeOrAbsolute), OverwriteOption.Overwrite, ct, uploadProgress);
            }
            catch (TaskCanceledException exception)
            {
                Console.WriteLine("Exception occured while uploading file to OneDrive : " + exception.Message);
            }
            catch (Exception e)
            {
            }
            return(1);
        }
예제 #21
0
        //---------------------------------------------------------------------------------------------------------



        //Bilder Speichern
        //---------------------------------------------------------------------------------------------------------
        void SaveImages()
        {
            try
            {
                //Bilder in neuen Style kopieren
                string NameToCreate = TBStyleName.Text;
                NameToCreate = NameToCreate.Trim();
                file.CreateDirectory("Sounds/ " + NameToCreate);
                file.CopyFile("TempSounds/BatteryLow.mp3", "Sounds/ " + NameToCreate + "/BatteryLow.mp3");
                file.CopyFile("TempSounds/BatteryIsCharging.mp3", "Sounds/ " + NameToCreate + "/BatteryIsCharging.mp3");
                file.CopyFile("TempSounds/BatteryFullyCharged.mp3", "Sounds/ " + NameToCreate + "/BatteryFullyCharged.mp3");
                //Bilderliste neu erstellen
                CreateImages();
                //Menü verbergen
                SPSaveImages.Visibility = System.Windows.Visibility.Collapsed;
                GRImagesOnline.Margin   = new Thickness(-600, 0, 0, 0);
                MenuOpen = false;
            }
            catch
            {
                MessageBox.Show(Lockscreen_Swap.AppResx.Z01_InUse);
                TBStyleName.Text = "";
            }
        }
예제 #22
0
        //---------------------------------------------------------------------------------------------------------



        //Neuen Ton kopieren
        //---------------------------------------------------------------------------------------------------------
        private void ChangeTempSound(object sender, RoutedEventArgs e)
        {
            //Alte Datei löschen
            if (file.FileExists("Sounds/" + StyleName + "/" + SelectFor + ".mp3"))
            {
                file.DeleteFile("Sounds/" + StyleName + "/" + SelectFor + ".mp3");
            }
            //Datei kopieren
            file.CopyFile("TempSounds/" + SelectFor + ".mp3", "Sounds/" + StyleName + "/" + SelectFor + ".mp3");

            //Grid verbergen
            GRSoundDownload.Margin = new Thickness(-600, 0, 0, 0);

            //Angeben das Menüs geschlossen sind
            MenuOpen = false;
        }
예제 #23
0
        /// <summary>
        /// Copy a file.
        /// </summary>
        /// <param name="newPath">The new full path of the file.</param>
        /// <param name="collisionOption">How to deal with collisions with existing files.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A task which will complete after the file is moved.</returns>
        public async Task CopyAsync(string newPath, NameCollisionOption collisionOption = NameCollisionOption.ReplaceExisting, CancellationToken cancellationToken = default(CancellationToken))
        {
            Requires.NotNullOrEmpty(newPath, "newPath");

            await AwaitExtensions.SwitchOffMainThreadAsync(cancellationToken);

            string newDirectory = System.IO.Path.GetDirectoryName(newPath);
            string newName      = System.IO.Path.GetFileName(newPath);

            for (int counter = 1; ; counter++)
            {
                cancellationToken.ThrowIfCancellationRequested();
                string candidateName = newName;
                if (counter > 1)
                {
                    candidateName = String.Format(
                        CultureInfo.InvariantCulture,
                        "{0} ({1}){2}",
                        System.IO.Path.GetFileNameWithoutExtension(newName),
                        counter,
                        System.IO.Path.GetExtension(newName));
                }

                string candidatePath = PortablePath.Combine(newDirectory, candidateName);

                if (_root.FileExists(candidatePath))
                {
                    switch (collisionOption)
                    {
                    case NameCollisionOption.FailIfExists:
                        throw new IOException("File already exists.");

                    case NameCollisionOption.GenerateUniqueName:
                        continue;     // try again with a new name.

                    case NameCollisionOption.ReplaceExisting:
                        _root.DeleteFile(candidatePath);
                        break;
                    }
                }

                _root.CopyFile(_path, candidatePath);
                _path = candidatePath;
                _name = candidateName;
                return;
            }
        }
        public static IsolatedStorageFileStream GetDatabaseStream()
        {
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!storage.FileExists("ClientsManager.sdf"))
                {
                    MessageBox.Show("Database file doesn't exists.");
                    return(null);
                }

                IsoStorageHelper.DeleteFile("ClientsManager_backup.sdf");

                //cannot access active database file, so have to make a copy
                storage.CopyFile("ClientsManager.sdf", "ClientsManager_backup.sdf");

                return(storage.OpenFile("ClientsManager_backup.sdf", FileMode.Open, FileAccess.Read));
            }
        }
예제 #25
0
        public void RestoreDatabase(string tmpPathDatabase)
        {
            dellAppDB.Dispose();
            //check downloaded database for version

            string tmpDBConnectionString = "Data Source=isostore:/" + tmpPathDatabase;

            // Create the database if it does not exist.
            using (DBClass tmpDB = new DBClass(tmpDBConnectionString))
            {
                if (tmpDB.DatabaseExists() == true)
                {
                    using (DBMigrator migrator = new DBMigrator(tmpDBConnectionString, App.DB_VERSION))
                    {
                        try
                        {
                            if (migrator.hasToMigrate())
                            {
                                migrator.MigrateDatabase();
                            }
                        }
                        catch (Exception e)
                        {
                            throw new Exception("Error during migration. Migration failed.");
                        }
                    }

                    // version are equal or db was migrated -> replace database files
                    tmpDB.Dispose();
                    IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
                    iso.CopyFile(tmpPathDatabase, AppResources.DatabaseName + ".sdf", true);

                    iso.Dispose();
                }
                else
                {
                    MessageBox.Show("Restore failed because the downloaded file is no database for this app.");
                }
            }

            this.ConnectDB();
        }
예제 #26
0
        public static void copyFileInIsolatedStorage(string sourceFilePath, string destinationFilePath)
        {
            sourceFilePath      = sourceFilePath.Replace(":", "_");
            destinationFilePath = destinationFilePath.Replace(":", "_");
            string sourceFileDirectory      = sourceFilePath.Substring(0, sourceFilePath.LastIndexOf("/"));
            string destinationFileDirectory = destinationFilePath.Substring(0, destinationFilePath.LastIndexOf("/"));

            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!myIsolatedStorage.DirectoryExists(sourceFileDirectory))
                {
                    return;
                }
                if (!myIsolatedStorage.DirectoryExists(destinationFileDirectory))
                {
                    myIsolatedStorage.CreateDirectory(destinationFileDirectory);
                }
                myIsolatedStorage.CopyFile(sourceFilePath, destinationFilePath);
            }
        }
예제 #27
0
 public virtual void SaveRepositories()
 {
     using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         if (store.FileExists(filename + ".bak"))
         {
             store.DeleteFile(filename + ".bak");
         }
         if (store.FileExists(filename))
         {
             store.CopyFile(filename, filename + ".bak");
             store.DeleteFile(filename);
         }
         using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(filename, FileMode.CreateNew, FileAccess.Write, store))
         {
             Serializer.Serialize(stream, repositories);
             stream.Close();
         }
         store.Close();
     }
 }
예제 #28
0
        private void updatePrimary(PodcastEpisodeModel currentEpisode)
        {
            ShellTile PrimaryTile = ShellTile.ActiveTiles.First();

            if (PrimaryTile != null)
            {
                StandardTileData tile = new StandardTileData();
                String           tileImageLocation        = "";
                String           podcastLogoLocalLocation = "";

                // Copy the logo file to tile's shared location.
                using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (var db = new PodcastSqlModel())
                    {
                        PodcastSubscriptionModel sub = db.Subscriptions.First(s => s.PodcastId == currentEpisode.PodcastId);
                        podcastLogoLocalLocation = sub.PodcastLogoLocalLocation;
                        tile.BackTitle           = sub.PodcastName;
                    }

                    if (myIsolatedStorage.FileExists(podcastLogoLocalLocation) == false)
                    {
                        // Cover art does not exist, we cannot do anything. Give up, don't put it to Live tile.
                        Debug.WriteLine("Podcasts cover art not found.");
                        return;
                    }

                    tileImageLocation = "Shared/ShellContent/" + podcastLogoLocalLocation.Split('/')[1];

                    if (myIsolatedStorage.FileExists(tileImageLocation) == false)
                    {
                        myIsolatedStorage.CopyFile(podcastLogoLocalLocation,
                                                   tileImageLocation);
                    }
                }

                tile.BackBackgroundImage = new Uri("isostore:/" + tileImageLocation, UriKind.Absolute);
                PrimaryTile.Update(tile);
            }
        }
        public override void CopyFile(string fileName, string sourcePath, string destinationPath, bool overwrite = false)
        {
            if (!FileExists(fileName, sourcePath))
            {
                throw new InvalidOperationException("File: " + fileName + ", does not exist.");
            }

            if (FileInUse(fileName, sourcePath))
            {
                throw new AccessViolationException("File: " + fileName + ", is in use.");
            }

            var sourceFullPath      = FilePathUtility.SetFullFilePath(fileName, sourcePath);
            var destinationFullPath = FilePathUtility.SetFullFilePath(fileName, destinationPath);

            if (!DirectoryExists(destinationPath))
            {
                CreateDirectory(destinationPath);
            }

            m_container.CopyFile(sourceFullPath, destinationFullPath, overwrite);
        }
예제 #30
0
        //---------------------------------------------------------------------------------------------------------


        //Profil anwenden
        //---------------------------------------------------------------------------------------------------------
        private void BtnSetProfil(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //Warnung ausgeben
            if (MessageBox.Show(Lockscreen_Swap.AppResx.Z02_WarningSetProfil, Lockscreen_Swap.AppResx.Warning, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                //Settings kopieren
                file.DeleteFile("/Settings/Settings.txt");
                file.CopyFile("/Profile/" + TBProfilMenuName.Text + ".txt", "/Settings/Settings.txt");

                //Create new erstellen
                if (!file.FileExists("CreateNew.txt"))
                {
                    IsolatedStorageFileStream filestream = file.CreateFile("CreateNew.txt");
                    StreamWriter sw = new StreamWriter(filestream);
                    sw.WriteLine(Convert.ToString("1"));
                    sw.Flush();
                    filestream.Close();
                }

                //Zurück zur Startseite
                NavigationService.GoBack();
            }
        }