看看这个,可能会帮上你的.
//上传
if (FileUpload1.HasFile)
{
string fileExt =
System.IO.Path.GetExtension(FileUpload1.FileName);
if (fileExt == ".mp3")
{
try
{
FileUpload1.SaveAs("D:\\Uploads\\1.mp3");
Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "" +
FileUpload1.PostedFile.ContentLength + " kb" +
"Content type: " +
FileUpload1.PostedFile.ContentType;
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
}
else
{
Label1.Text = "Only .mp3 files allowed!";
}
if (fileExt == ".rm")
{
try
{
FileUpload1.SaveAs("D:\\Uploads\\" +
FileUpload1.FileName);
}
catch
{
}
}
}
else
{
Label1.Text = "You have not specified a file.";
}