Книга: C# 2008 Programmer
Deleting a Photo
Deleting a Photo
To delete a photo, the user first selects a photo to delete and then you call the PerformWebRequest()
helper function you have defined earlier:
private void btnDeletePhoto_Click(object sender, EventArgs e) {
if (TreeView1.SelectedNode.ImageIndex != ico_PHOTO) {
MessageBox.Show("Please select a photo to delete.");
return;
} try {
string FullPath = Properties.Settings.Default.FTP_SERVER +
TreeView1.SelectedNode.FullPath.Substring(1).Replace("r", "");
//---delete the photo---
FtpWebResponse ftpResp =
PerformWebRequest(FullPath, WebRequestMethod.DeleteFile);
//---delete the current node---
TreeView1.SelectedNode.Remove();
//---update the statusbar---
ToolStripStatusLabel1.Text =
ftpResp.StatusDescription.Replace("rn", string.Empty);
} catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
}
Once the photo is removed from the FTP server, you also need to delete its node in the TreeView
control.
- Creating Database Users in PostgreSQL
- Creating the Application
- Creating a New Directory
- Removing a Directory
- Uploading Photos
- Testing the Application
- Creating and Deleting Device Objects
- Deleting Users
- Deleting Database Users in PostgreSQL
- Deleting Files and Directories with rm
- Deleting volumes and volume sets
- Changing or deleting the volume label