/// <summary> /// Call when you are ready to pull down the data associated with this object /// </summary> public void Update(bool force = false) { if (!force && (Opened || (RemoteFile != null && !RemoteFile.IsDirectory()))) { return; } // if we are forcing an update then the assumption is that we want an update // of either the current item or its container. If this is not a directory and // we have been forced, force an update on the parent if (force && !IsApplication && (RemoteFile != null && !RemoteFile.IsDirectory())) { if (this.Parent != null) { this.Parent.Update(force: true); } return; } Children.Clear(); //Opened = true; Opened = true; IRemoteIsolatedStorageFile remoteIso = _remoteStore; if (remoteIso == null) { if (RemoteApp.InstanceID == Guid.Empty) { // 8.1 UpdateModern(force); return; } else { remoteIso = RemoteApp.GetIsolatedStore("Local"); } } List <IRemoteFileInfo> remoteFiles; try { if (remoteIso != null) { remoteFiles = remoteIso.GetDirectoryListing(_path); foreach (IRemoteFileInfo remoteFile in remoteFiles) { Children.Add(new RemoteAppIsoStoreItem(_appEx, remoteFile, remoteIso, this)); } } } catch (FileNotFoundException) { // no files, oh well :) } }
/// <summary> /// Copies the remote item to the path specified. If this is a directory then it /// will recursively copy it down. /// </summary> /// <param name="path">Returns the full local path (i.e. localPath + [file/dir]name)</param> public string Get(string localPath, bool overwrite) { string fullLocalPath = Path.Combine(localPath, Path.GetFileName(Name)); if (IsApplication || IsRemoteStore || RemoteFile.IsDirectory()) { Directory.CreateDirectory(fullLocalPath); // make sure we know about all of our children Update(); foreach (RemoteAppIsoStoreItem item in Children) { item.Get(fullLocalPath, overwrite); } } else { if (overwrite || !File.Exists(fullLocalPath)) { _remoteStore.ReceiveFile(_path, fullLocalPath, true); } } return(fullLocalPath); }
public void Put(string localFile, bool overwrite = false) { // relative directory is: // "" - if it's an application // _path - if it's a directory (since Path.GetDirectoryName will actually strip out the directory name) // Path.GetDirectoryName(_path) - if it's a file, since this will strip out the file name and leave us with a directory string relativeDirectory = (RemoteFile == null ? "" : (RemoteFile.IsDirectory() ? _path : Path.GetDirectoryName(_path))); Put(localFile, relativeDirectory, overwrite); }
public void Delete() { if (IsApplication) { // delete everything under this application Update(); foreach (RemoteAppIsoStoreItem item in Children) { item.Delete(); } // leave things in a clean state with the default directories. If the user // really wants to kill these they can delete them individually string shared = Path.Combine(_path, "Shared"); _remoteStore.CreateDirectory(shared); _remoteStore.CreateDirectory(Path.Combine(shared, "Transfers")); _remoteStore.CreateDirectory(Path.Combine(shared, "ShellContent")); } else if (RemoteFile.IsDirectory()) { _remoteStore.DeleteDirectory(_path); } else { // really? no delete file??? RemoteIsolatedStorageFile is hidden (internal) within the wrapper // not sure if there is an easy way to get it var remoteFileObject = _remoteStore as RemoteIsolatedStorageFileObject; if (remoteFileObject != null) { remoteFileObject.GetRemoteIsolatedStorageFile().DeleteFile(_path); } } }