public override sealed void UpdateParameters() { var native = ((NativeDirectoryInfo)NativeSystemInfo); NativeSystemInfo = new NativeDirectoryInfo(native.PIDL, native.Parent); Icon = NativeSystemInfo.Icon; }
public RootDirectoryViewModel(NativeDirectoryInfo nativeDirectoryInfo, IDirectoryViewModel parent) : base(nativeDirectoryInfo, parent) { NativeSystemInfo = nativeDirectoryInfo; var directoryUnfo = new DirectoryInfo(nativeDirectoryInfo.Path); var subDirectoryProvider = new SubDirectoriesProvider(directoryUnfo, this); var filesProvider = new FilesProvider(directoryUnfo, this); DisplayName = nativeDirectoryInfo.DisplayName; Path = nativeDirectoryInfo.Path; VisualPath = Parent.VisualPath + "\\" + DisplayName; //is drive? DriveInfo driveInfo = Drives.FirstOrDefault(info => PathHelper.NormalizePath(info.Name) == PathHelper.NormalizePath(Path)); HasItems = driveInfo?.IsReady ?? directoryUnfo.EnumerateDirectories().Any(); SubDirectories = new AsyncLoadCollection <IDirectoryViewModel>(subDirectoryProvider); SubDirectories.CollectionChanged += _subDirectories_CollectionChanged; Files = new AsyncLoadCollection <ISystemObjectViewModel>(filesProvider); Children = new UnionCollectionEx <IDirectoryViewModel, ISystemObjectViewModel, ISystemObjectViewModel>(SubDirectories, Files); }
private void btnOK_Click(object sender, EventArgs e) { double ExcludeFileSize = double.PositiveInfinity; try { btnOK.Enabled = false; tbSrcFolder.Text = Utility.StripTrailingSlash(tbSrcFolder.Text); tbBackupFolder.Text = Utility.StripTrailingSlash(tbBackupFolder.Text); // If specifying a root folder, then we actually need the trailing slash due to some quarks in Windows. It also looks nice. if (tbSrcFolder.Text.Length == 2 && tbSrcFolder.Text[1] == ':') { tbSrcFolder.Text = tbSrcFolder.Text + "\\"; } if (tbBackupFolder.Text.Length == 2 && tbBackupFolder.Text[1] == ':') { tbBackupFolder.Text = tbBackupFolder.Text + "\\"; } string CompleteBackupFolder; for (; ;) { try { Path.GetFullPath(tbBackupFolder.Text); } catch (Exception) { MessageBox.Show("Please provide a valid backup folder path."); return; } CompleteBackupFolder = tbBackupFolder.Text + "\\" + tbProjectName.Text; try { if (tbProjectName.Text.Contains("\\")) { throw new Exception(); } Path.GetFullPath(CompleteBackupFolder); } catch (Exception) { MessageBox.Show("Please ensure that the project name is a valid filename. It cannot include any of the following characters: \\ / : * ? \" < > |"); return; } try { using (NetworkConnection newconn = new NetworkConnection(tbSrcFolder.Text, m_Project.SourceCredentials)) { NativeDirectoryInfo.CheckAccessToDirectory(tbSrcFolder.Text); } } catch (DirectoryNotFoundException) { if (MessageBox.Show("The source folder does not exist or is offline. ZippyBackup cannot verify access to the folder at this time.", "Warning", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) { return; } } catch (System.Security.Authentication.InvalidCredentialException) { MessageBox.Show("The credentials provided do not have access to the source folder. Please use the Security tab to provide proper credentials."); return; } catch (System.IO.IOException ex) { MessageBox.Show(ex.Message); return; } try { using (NetworkConnection newself = new NetworkConnection(tbBackupFolder.Text, m_Project.BackupCredentials)) { NativeDirectoryInfo.CheckAccessToDirectory(tbBackupFolder.Text); } } catch (DirectoryNotFoundException) { if (MessageBox.Show("The backup folder does not exist. Would you like to create it?", "Question", MessageBoxButtons.YesNo) == DialogResult.No) { return; } Directory.CreateDirectory(tbBackupFolder.Text); } catch (System.Security.Authentication.InvalidCredentialException) { MessageBox.Show("The credentials provided do not have access to the backup folder. Please use the Security tab to provide proper credentials."); return; } catch (System.IO.IOException ex) { MessageBox.Show(ex.Message); return; } #if false if (cbUseVSS.Checked) { if (m_Project.BackupCredentials.Provided) { MessageBox.Show("Cannot support credentials for the backup user (besides the user launching ZippyBackup) and also for Volume Shadow Service access (administrator)."); return; } if (!m_Project.SourceCredentials.Provided) { NetworkCredential Credential = CredentialsPrompt.PromptForCredentials( CredentialsPrompt.ServerNameFromPath(new DirectoryInfo(tbSrcFolder.Text).Root.Name), "Credentials are required to take a Volume Shadow Service snapshot."); if (Credential == null) { m_Project.SourceCredentials.Clear(); return; } m_Project.SourceCredentials = new StoredNetworkCredentials(Credential); } } #endif break; } # if false if (!Directory.Exists(tbSrcFolder.Text)) { MessageBox.Show("The source folder does not exist! If the folder is offline, please bring it online for the setup process."); return; } if (!Directory.Exists(tbBackupFolder.Text)) { if (MessageBox.Show("The backup folder does not exist. Would you like to create it?", "Question", MessageBoxButtons.YesNo) == DialogResult.No) { return; } Directory.CreateDirectory(tbBackupFolder.Text); } # endif if (Utility.IsContainedIn(tbSrcFolder.Text, tbBackupFolder.Text))
public NativeFilesProvider(NativeDirectoryInfo directoryInfo, IDirectoryViewModel parent) { Parent = parent; _directoryInfo = directoryInfo; }
public NativeSubDirectoryProvider(NativeDirectoryInfo systemInfo, IDirectoryViewModel parent) { _systemInfo = systemInfo; Parent = parent; }