目前分類:ASP.NET (3)

瀏覽方式: 標題列表 簡短摘要

using System.Net.Mail;
 
MailMessage msg = new MailMessage();

jhe 發表在 痞客邦 留言(0) 人氣()

(DetailsView1.FindControls("TextBox1") as TextBox).Text

http://s.yanghao.org/program/viewdetail.php?i=162930


jhe 發表在 痞客邦 留言(0) 人氣()

 1: protected void FileUploadButton_Click(object sender, EventArgs e)
 2: {
 3:  
 4:     Boolean FileOK = false;
 5:     string FilePath = "D:\\upload\\"; //設定上傳的路徑
 6:     if (FileUploadField.HasFile)
 7:     {
 8:         string fileExtension = System.IO.Path.GetExtension(FileUploadField.FileName).ToLower(); //如果副檔名有大寫則將他轉為小寫
 9:         string[] allowExtensions = { ".zip", ".rar", ".7z", ".doc", ".docx" }; //允許的檔案類型
 10:         for (int i = 0; i < allowExtensions.Length; i++)
 11:         {
 12:             if (fileExtension == allowExtensions[i])
 13:             {
 14:                 FileOK = true;
 15:             }
 16:         }
 17:     }
 18:  
 19:  
 20:  
 21:     if (FileOK)
 22:     {
 23:         try
 24:         {
 25:             string tmpFileName = FileUploadField.FileName;
 26:             string Date = DateTime.Now.ToString("MM-dd-hh-mm");
 27:             tmpFileName = Date + "_" + FileUploadField.FileName;
 28:             FileUploadField.PostedFile.SaveAs(FilePath + tmpFileName);
 29:             UploadedMessage.Text = "你所上傳的檔案為「" + FileUploadField.FileName + "」<br/>上傳成功";
 30:         }
 31:         catch (Exception ex)
 32:         {
 33:             UploadedMessage.Text = "上傳失敗";
 34:         }
 35:     }
 36:     else
 37:     {
 38:         UploadedMessage.Text = "不允許此類型檔案的上傳";
 39:     }
 40: }

jhe 發表在 痞客邦 留言(0) 人氣()