Нам нужно также убедиться в том, что новые кнопки и текстовое поле включаются и отключаются в соответствующее время. Чтобы включить их, когда выводится содержимое файла, мы добавляем следующий код в DisplayFileInfo():
protected void DisplayFileInfo(string fileFullName) {
FileInfo TheFile = new FileInfo(fileFullName);
if (!TheFile.Exists) throw new FileNotFoundException("File not found: " + fileFullName);
txtBoxFileName.Text = TheFile.Name;
txtBoxCreationTime.Text = TheFile.CreationTime.ToLongTimeString();
txtBoxLastAccessTime.Text = TheFile.LastAccessTime.ToLongDateString();
txtBoxLastWriteTime.Text = TheFile.LastWriteTime.ToLongDateString();
txtBoxFileSize.Text = TheFile.Length.ToString() + " bytes";
// включает кнопки перемещения, копирования и удаления
txtBoxNewPath.Text = TheFile.FullName;
txtBoxNewPath.Enabled = true;
buttonCopyTo.Enabled = true;
buttonDelete.Enabled = true;
buttonMoveTo.Enabled = true;
}
Нам нужно также сделать одно изменение в DisplayFolderInfo:
protected void DisplayFolderList(string folderFullName) {
DirectoryInfo TheFolder = new DirectoryInfo(folderFullName);
if (!TheFolder.Exists)
throw new DirectoryNotFoundException("Folder not found: " + folderFullName);
ClearAllFields();
DisableMoveFeatures();
txtBoxFolder.Text = TheFolder.FullName;
currentFolderPath = TheFolder.FullName;
// перечислить все папки, вложенные в папку
foreach(DirectoryInfo NextFolder in TheFolder.GetDirectories())
listBoxFolders.Items.Add(NextFolder.Name);
// перечислить все файлы в папке
foreach (FileInfo NextFile in TheFolder.GetFiles())