关于C#结构体的保存的问题
public struct DirItemType
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public char[] Name; // 用空格扩展填充的文件名
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public char[] Ext; // 用空格扩展填充的扩展名
public byte Attr; // 属性,$00表示普通文件 $10表示子目录
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public byte[] Reserved; // 保留
public ushort CTime; // 文件创建的时间,专门格式
public ushort CDate; // 文件创建的日期,专门格式
public ushort Cluster; // 文件存储位置的簇号
public uint Length; // 以字节为单位的文件长度,
}
上面是结构体,下面是方法
if (SCL_API_DLL.SCL_ReceiveData(0, i * 32, 32, ref buff[0]))
{
DirItemType diritemtype = new DirItemType();
diritemtype = (DirItemType)BytesToStuct(buff, typeof(DirItemType));
string FileName = new string(diritemtype.Name).Replace('\0', ' ').Trim();
string Ext = new string(diritemtype.Ext).Replace('\0', ' ').Trim();
if (Ext=="R01")
{
List<DirItemType> dt = new List<DirItemType>();
//将符合条件的保存下来
MessageBox.Show(FileName+"."+Ext);
//LoadR01File(dt);
这个结构体里面保存了数据,我要找到Ext=R01的所有数据,然后保存,我现在不知道保存到什么地方,怎么保存,保存到列表呢?还是?