public void Rename(FileObject file, string newName) { if (file.Name == newName) return; string path = CombineName(file.Directory, newName, file.Extension); while (File.Exists(path)) { string rndtx = Path.GetRandomFileName(); path = CombineName(file.Directory, string.Format("{0}_{1}", newName, rndtx), file.Extension); } File.Move(file.Path, path); File.Delete(file.Path); }
/// <summary> /// fill the items to file list box /// </summary> private void SetFileItems(FileObject[] collection) { FileListBox.Items.Clear(); if (collection != null) { FileListBox.Items.AddRange(collection); } }