본문 바로가기

Programing (프로그래밍)/WPF & C# (C Sharp)

WPF & C# - NPKI 공인인증서 폴더 위치 열기 ( Folder Open Path )

728x90
반응형


 WPF & C# - NPKI 공인인증서 폴더 위치 열기 ( Folder Open Path )


PathNPKI.zip


PathNPKI.exe


MainWindow.xaml



1
2
3
<Grid>
    <Button x:Name="btn" Content="NPKI 폴더 열기" Click="btn_Click" Margin="10"/>
</Grid>
cs




MainWindow.xaml.cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
private void btn_Click(object sender, RoutedEventArgs e)
{
    AppData_NPKI();
    Path_NPKI();
    Path_x86_NPKI();
}
 
//인증서 목록 불러오기 - AppData_NPKI
private void AppData_NPKI()
{
    string path = string.Empty;
    string strsub = string.Empty;
 
    DataTable dt = null;
    DataRow dr = null;
 
    dt_create01(ref dt);
 
    // C:\\Users\\사용자명\\AppData\\
    path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).ToString();
    path += "\\AppData\\LocalLow\\NPKI\\yessign\\USER\\";
 
    System.IO.DirectoryInfo dirinfo = new System.IO.DirectoryInfo(path);
    foreach (var item in dirinfo.GetDirectories())
    {
        dr = dt.Rows.Add();
        dr["NPKI"= item.Name.ToString();
    }
 
    if (dt.Rows.Count > 0)
    {
        // 폴더 열기
        System.Diagnostics.Process.Start(path);
 
        /*
        foreach (DataRow item in dt.Rows)
        {
            MessageBox.Show(item["NPKI"].ToString());
        }
        */
    }
}
 
private void dt_create01(ref DataTable dt)
{
    try
    {
        dt = new DataTable();
 
        dt.Columns.Add("NPKI");
    }
    catch (Exception ex)
    {
        // MessageBox.Show(ex.Message.ToString());
    }
}
 
private void Path_x86_NPKI()
{
    string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86).ToString() + "\\NPKI\\yessign\\USER\\";
 
    DirectoryInfo di = new DirectoryInfo(path);
    if (di.Exists)
    {
        DirectoryInfo dirinfo = new DirectoryInfo(path);
        if (dirinfo.GetDirectories().Count() > 0)
        {
            // 폴더 열기
            System.Diagnostics.Process.Start(path);
        }
    }
}
 
private void Path_NPKI()
{
    string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles).ToString() + "\\NPKI\\yessign\\USER\\";
 
    DirectoryInfo di = new DirectoryInfo(path);
    if (di.Exists)
    {
        DirectoryInfo dirinfo = new DirectoryInfo(path);
        if (dirinfo.GetDirectories().Count() > 0)
        {
            // 폴더 열기
            System.Diagnostics.Process.Start(path);
        }
    }
}
cs




728x90
반응형