프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / UploadFonts / Default.aspx.cs @ 950e6b84

이력 | 보기 | 이력해설 | 다운로드 (1.82 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Web;
5
using System.Web.UI;
6
using System.Web.UI.WebControls;
7
using System.Configuration;
8
using System.IO;
9

    
10
namespace UploadFonts
11
{
12
    public partial class _Default : Page
13
    {
14
        protected void Page_Load(object sender, EventArgs e)
15
        {
16
            
17
        }
18

    
19
        protected void btnUpload_Click(object sender, EventArgs e)
20
        {
21
            if ((FileUpload1.PostedFile != null) && (FileUpload1.PostedFile.ContentLength > 0))
22
            {
23
                var count = 0;
24
                string log = "";
25

    
26
                string fontFoler = Properties.Settings.Default.FontFoler + "\\";
27

    
28
                var directoryInfo = new DirectoryInfo(fontFoler);
29
                if (!directoryInfo.Exists)
30
                {
31
                    directoryInfo.Create();
32
                }
33

    
34
                foreach (HttpPostedFile uploadedFile in FileUpload1.PostedFiles)
35
                {
36
                    string fn = System.IO.Path.GetFileName(uploadedFile.FileName);
37

    
38

    
39
                    string SaveLocation = fontFoler + "\\" + fn;
40
                    try
41
                    {
42
                        uploadedFile.SaveAs(SaveLocation);
43
                        log += uploadedFile.FileName + Environment.NewLine;
44
                        count++;
45
                    }
46
                    catch (Exception ex)
47
                    {
48
                        FileUploadStatus.Text = "Error: " + ex.Message;
49
                    }
50
                }
51

    
52
                if (count > 0)
53
                {
54
                    FileUploadStatus.Text = log +  Environment.NewLine + " files has been uploaded.";
55
                }
56
            }
57
            else
58
            {
59
                FileUploadStatus.Text = "Please select a file to upload.";
60
            }
61
        }
62
    }
63
}
클립보드 이미지 추가 (최대 크기: 500 MB)