The complete version of the Default.aspx.cs file for this chapter, including comments, is shown in the following code block:
using System;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
string savePath = @"c:\data\uploads\"; //make upload directory
if (FileUpload1.HasFile)
{
string fileName = FileUpload1.FileName;//get file name
savePath += fileName;//attach file name to save path
FileUpload1.SaveAs(savePath);//save file
sampLabel.Text = "<br>Your file was saved as " + fileName;
}
else
{
sampLabel.Text = "<br>You did not specify a file to upload.";
}
//could also use savePath here
string sourceDirectory = @"C:\data\uploads...