using System.Net.Mail;
MailMessage msg = new MailMessage();
目前分類:ASP.NET (3)
- Jan 18 Fri 2013 13:20
C# .net 2.0 以Gmail發送Smtp郵件
- Jan 18 Fri 2013 13:18
net DetailsView 控件中取值问题!
(DetailsView1.FindControls("TextBox1") as TextBox).Text
http://s.yanghao.org/program/viewdetail.php?i=162930
- Aug 23 Thu 2012 07:07
FileUpload 檔案上傳
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: }