System.IO.Path.GetDirectoryName(choofdlog.FileName);

'C#' 카테고리의 다른 글

(.NET) GetDateTimeFormats()  (0) 2017.04.15
(.NET) TcpListener  (0) 2017.04.15
(.NET) 파일 전체 경로에서 directory 정보만 뺴오기  (0) 2017.04.15
(.NET) 다른 config 파일 읽어오기  (0) 2017.04.15
(.NET) List<T> To Table  (0) 2017.04.15
(.NET) 작업표시줄 깜빡이기  (0) 2017.04.15
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = configFileName;

Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
ConnectionStringsSection conStrSection = configuration.ConnectionStrings as ConnectionStringsSection;

foreach (ConnectionStringSettings con in conStrSection.ConnectionStrings)

{
}

configuration.AppSettings.Settings.AllKeys.GetEnumerator();

configuration.AppSettings.Settings["TEST"].Value.ToString();

public static DataTable ToDataTable<T>(this IList<T> data)
    {
        PropertyDescriptorCollection properties =
            TypeDescriptor.GetProperties(typeof(T));
        DataTable table = new DataTable();
        foreach (PropertyDescriptor prop in properties)
            table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
        foreach (T item in data)
        {
            DataRow row = table.NewRow();
            foreach (PropertyDescriptor prop in properties)
                 row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
            table.Rows.Add(row);
        }
        return table;
    }

+ Recent posts