//[StructLayout(LayoutKind.Sequential)] //struct Fuga { // public double A; // public double B; // public double C; // public string name; //} //void Test3_Pointer() { // IntPtr ptr= IntPtr.Zero; // unsafe { // Fuga obj = *(Fuga*)ptr; // } //} //public List<MFTFile> GetFile(Win32.MFT_FILE_INFO[] aryFileInfo) { public List<MFTFile> GetFile() { TimeSpan utcOffset = System.TimeZoneInfo.Local.BaseUtcOffset; var baseticks = new DateTime(1601, 01, 01).Ticks + utcOffset.Ticks; var list = new List<MFTFile>(); int start = 27; if (aryFileInfo == null) return list; if (aryFileInfo.Count() < start) { list.Clear(); return list; } int count = aryFileInfo.Count(); for (int i = start; i < count; i++) { if (aryFileInfo[i].Name != null) { List<Int64> stack = new List<Int64>(); //var record = aryFileInfo[i]; Int32 parent = (Int32)aryFileInfo[i].DirectoryFileReferenceNumber; while (parent != 5 && parent < count) { stack.Add(parent); parent = (Int32)aryFileInfo[parent].DirectoryFileReferenceNumber; } stack.Reverse(); StringBuilder buf = new StringBuilder(); buf.Append(drive.Name); foreach (var item in stack) { buf.Append(aryFileInfo[item].Name); buf.Append(@"\"); } //buf.Append(aryFileInfo[i].Name); var record = aryFileInfo[i]; MFTFile file = new MFTFile(); file.Path = buf.ToString(); file.Name = record.Name; file.Size = (long)record.Size; file.IsDirectory = record.IsDirectory; file.CreationTime = new DateTime((long)record.CreationTime + baseticks); //file.LastAccessTime = new DateTime((long)record.LastAccessTime + baseticks); file.LastWriteTime = new DateTime((long)record.LastWriteTime + baseticks); list.Add(file); } } //Win32.freeBuffer(pListA); aryFileInfo = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); return list; }
//[StructLayout(LayoutKind.Sequential)] //struct Fuga { // public double A; // public double B; // public double C; // public string name; //} //void Test3_Pointer() { // IntPtr ptr= IntPtr.Zero; // unsafe { // Fuga obj = *(Fuga*)ptr; // } //} //public List<MFTFile> GetFile(Win32.MFT_FILE_INFO[] aryFileInfo) { public List <MFTFile> GetFile() { TimeSpan utcOffset = System.TimeZoneInfo.Local.BaseUtcOffset; var baseticks = new DateTime(1601, 01, 01).Ticks + utcOffset.Ticks; var list = new List <MFTFile>(); int start = 27; if (aryFileInfo == null) { return(list); } if (aryFileInfo.Count() < start) { list.Clear(); return(list); } int count = aryFileInfo.Count(); for (int i = start; i < count; i++) { if (aryFileInfo[i].Name != null) { List <Int64> stack = new List <Int64>(); //var record = aryFileInfo[i]; Int32 parent = (Int32)aryFileInfo[i].DirectoryFileReferenceNumber; while (parent != 5 && parent < count) { stack.Add(parent); parent = (Int32)aryFileInfo[parent].DirectoryFileReferenceNumber; } stack.Reverse(); StringBuilder buf = new StringBuilder(); buf.Append(drive.Name); foreach (var item in stack) { buf.Append(aryFileInfo[item].Name); buf.Append(@"\"); } //buf.Append(aryFileInfo[i].Name); var record = aryFileInfo[i]; MFTFile file = new MFTFile(); file.Path = buf.ToString(); file.Name = record.Name; file.Size = (long)record.Size; file.IsDirectory = record.IsDirectory; file.CreationTime = new DateTime((long)record.CreationTime + baseticks); //file.LastAccessTime = new DateTime((long)record.LastAccessTime + baseticks); file.LastWriteTime = new DateTime((long)record.LastWriteTime + baseticks); list.Add(file); } } //Win32.freeBuffer(pListA); aryFileInfo = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); return(list); }