本文整理汇总了C#中System.IO.FileInfo.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.GetType方法的具体用法?C# FileInfo.GetType怎么用?C# FileInfo.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1
public Form1()
{
FileInfo fi = new FileInfo(@"c:\temp\DeviceFile.cs");
InitializeComponent();
propertyGrid1.SelectedObject = fi;
propertyGrid2.SelectedObject = fi.GetType();
}
示例2: GetFileItemInfo
/// <summary>
/// Récupérer les infos du fichier
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
public IExplorerItem GetFileItemInfo(FileInfo fileInfo)
{
return new FileItem
{
Path = fileInfo.FullName,
Name = fileInfo.Name,
ModifiedDate = fileInfo.LastWriteTime,
Type = fileInfo.GetType().Name,
Size = fileInfo.Length,
ChildItems = null
};
}
示例3: File
public File( FileInfo _file ) {
m_file = _file;
m_size = _file.Length;
m_extension = _file.Extension.ToLower();
try {
m_fullName = m_file.FullName;
} catch ( Exception ) {
// System.Reflection.PropertyInfo hiddenPathProperty = m_file.GetType().GetProperty( "FullPath", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance );
// System.Reflection.PropertyInfo[] hiddenPathProperties = m_file.GetType().GetProperties( System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance );
// System.Reflection.FieldInfo[] hiddenPathFields = m_file.GetType().GetFields( System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance );
// System.Reflection.FieldInfo hiddenPathField = hiddenPathFields.Single( ( pi ) => { return pi.Name == "FullPath"; } );
System.Reflection.FieldInfo hiddenPathField = m_file.GetType().GetField( "FullPath", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance );
m_fullName = hiddenPathField != null ? hiddenPathField.GetValue( m_file ) as string : m_file.Name;
}
}
示例4: GetObjectProperty
/**
* �����ȫ�����Ժ�����ֵ��������дjson��{}������
* ���ɺ�ĸ�ʽ����
* "����1":"����ֵ"
* ����Щ������������ֵд���ַ����б����
* */
private List<string> GetObjectProperty(FileInfo o)
{
List<string> propertyslist = new List<string>();
PropertyInfo[] propertys = o.GetType().GetProperties();
foreach (PropertyInfo p in propertys)
{
propertyslist.Add("\"" + p.Name.ToString() + "\":\"" + p.GetValue(o, null) + "\"");
}
return propertyslist;
}
示例5: Main
static void Main(string[] args)
{
FileInfo fi = new FileInfo(@"c:\temp\DeviceFile.cs");
Console.WriteLine(fi.GetType().FullName);
}