c#调用API操作文件,很久以前写的
1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 using System.IO; 5 using System.Runtime.InteropServices; 6 using Microsoft.Win32; 7 using System.Security.Cryptography; 8 using System.Diagnostics; 9 10 11 namespace MyTool 12 { 13 /// <summary> 14 /// 文件md5的读取 15 /// </summary> 16 public class md5 17 { 18 /// <summary> 19 /// 实现对一个文件md5的读取,path为文件路径 20 /// </summary> 21 /// <param name="path"></param> 22 /// <returns></returns> 23 public static string md5_hash(string path) 24 { 25 try 26 { 27 FileStream get_file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); 28 System.Security.Cryptography.MD5CryptoServiceProvider get_md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); 29 byte[] hash_byte = get_md5.ComputeHash(get_file); 30 string resule = System.BitConverter.ToString(hash_byte); 31 resule = resule.Replace("-", ""); 32 return resule; 33 } 34 catch (Exception e) 35 { 36 return e.ToString(); 37 } 38 39 } 40 41 /// <summary> 42 /// 将指定字符串进行MD5加密 43 /// </summary> 44 public static string GetMD5str(string oldStr) 45 { 46 try 47 { 48 //将输入转换为ASCII 字符编码 49 ASCIIEncoding enc = new ASCIIEncoding(); 50 //将字符串转换为字节数组 51 byte[] buffer = enc.GetBytes(oldStr); 52 //创建MD5实例 53 MD5 md5 = new MD5CryptoServiceProvider(); 54 //进行MD5加密 55 byte[] hash = md5.ComputeHash(buffer); 56 StringBuilder sb = new StringBuilder(); 57 //拼装加密后的字符 58 for (int i = 0; i < hash.Length; i++) 59 { 60 sb.AppendFormat("{0:x2}", hash[i]); 61 } 62 //输出加密后的字符串 63 return sb.ToString(); 64 } 65 catch (Exception ex) 66 { 67 return ex.Message; 68 } 69 } 70 71 } 72 class fileinfo 73 { 74 public const int INVALID_HANDLE_VALUE = -1;//没找到文件 75 public const int FILE_ATTRIBUTE_DIRECTORY = 16;//找到的是目录 76 public const int FILE_ATTRIBUTE_READONLY = 1; 77 public const int FILE_ATTRIBUTE_HIDDEN = 2; 78 public const int FILE_ATTRIBUTE_SYSTEM = 4; 79 public const int FILE_ATTRIBUTE_ARCHIVE = 32;//存档 80 public const int FILE_ATTRIBUTE_NORMAL = 128; 81 public const int FILE_ATTRIBUTE_TEMPORARY = 256; 82 public const int INVALID_FILE_ATTRIBUTES = -1; 83 public const int FILE_ATTRIBUTE_DEVICE = 64; 84 public const int FILE_ATTRIBUTE_SPARSE_FILE = 512; 85 public const int FILE_ATTRIBUTE_REPARSE_POINT = 1024; 86 public const int FILE_ATTRIBUTE_COMPRESSED = 2048; 87 public const int FILE_ATTRIBUTE_OFFLINE = 4096; 88 public const int FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192; 89 public const int FILE_ATTRIBUTE_ENCRYPTED = 16384; 90 public const int MOVEFILE_COPY_ALLOWED = 2;//如移动到一个不同的卷,则复制文件并删除原来的文件 91 public const int MOVEFILE_CREATE_HARDLINK = 16;//系统保留,以供将来使用 92 public const int MOVEFILE_DELAY_UNTIL_REBOOT = 4;//移动操作在系统下次重新启动时正式进行 93 public const int MOVEFILE_FAIL_IF_NOT_TRACKABLE = 32;// 94 public const int MOVEFILE_REPLACE_EXISTING = 1;//如目标文件存在,则将其替换 95 public const int MOVEFILE_WRITE_THROUGH = 8;//这个标记允许函数在执行完文件移动操作后才返回,否者不等文件移动完毕就直接返回 96 //如果设置了 MOVEFILE_DELAY_UNTIL_REBOOT 标记,则 MOVEFILE_WRITE_THROUGH 标记将被忽略。 97 98 /// <summary> 99 /// 为一个指定的文件或目录返回文件系统的属性,当该函数作用在一个挂载文件夹时,它返回目录的文件系统的属性,而不是根目录的信息 100 /// </summary> 101 /// <param name="filepath"></param> 102 /// <returns></returns> 103 [DllImport("Kernel32.dll")] 104 public static extern int GetFileAttributes(string filepath); 105 106 [DllImport("kernel32.dll")] 107 public static extern bool SetFileAttributes(string lpFileName, int dwFileAttributes); 108 [DllImport("kernel32.dll")] 109 public static extern bool GetFileTime(int hFile,ref FILETIME lpCreationTime, //用于装载文件的创建时间 110 ref FILETIME lpLastAccessTime,//用于装载文件上一次访问的时间(FAT文件系统不支持这一特性) 111 ref FILETIME lpLastWriteTime);//用于装载文件上一次修改的时间 112 [DllImport("kernel32.dll")] 113 public static extern int GetLastError(); 114 [DllImport("Kernel32.dll")] 115 public static extern bool DeleteFile(string lpFileName); 116 [DllImport("Kernel32.dll")] 117 public static extern bool RemoveDirectory(string lpDirectoryName); 118 119 [DllImport("Kernel32.dll")] 120 public static extern bool MoveFileEx(string lpExistingFileName,string newfilename,int dwFlags); 121 [DllImport("Kernel32.dll")] 122 public static extern bool CreateDirectory(string lpPathName, ref SECURITY_ATTRIBUTES pSecurityAttributes); 123 [DllImport("Kernel32.dll")] 124 public static extern int CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, ref SECURITY_ATTRIBUTES lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, int hTemplateFile); 125 126 /// <summary> 127 /// 执行删除。成功返回空,否则返回错误信息 128 /// </summary> 129 /// <param name="lpFileOp"></param> 130 /// <returns></returns> 131 [DllImport("shell32.dll")] 132 public static extern int SHFileOperation(ref SHFILEOPSTRUCT lpFileOp); 133 134 /// <summary> 135 /// 136 /// </summary> 137 /// <param name="lpExistingFileName">源文件名</param> 138 /// <param name="lpNewFileName">目标文件名</param> 139 /// <param name="bFailIfExists">是否覆盖</param> 140 /// <returns></returns> 141 [DllImport("Kernel32.dll")] 142 public static extern bool CopyFile(string lpExistingFileName, string lpNewFileName, bool bFailIfExists); 143 [DllImport("Kernel32.dll")] 144 public static extern bool MoveFile(string lpExistingFileName, string lpNewFileName); 145 [DllImport("Kernel32.dll")] 146 public static extern void WinExec(string lpCmdLine, uint uCmdShow); 147 /// <summary> 148 /// 关闭FindFirstFile创建的搜索句柄 149 /// </summary> 150 /// <param name="hFindFile"></param> 151 /// <returns></returns> 152 [DllImport("kernel32.dll")] 153 public static extern bool FindClose(int hFindFile);// file search handle 154 [System.Runtime.InteropServices.DllImport 155 ("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)] 156 public static extern int FindFirstFile(string lpFileName, ref WIN32_FIND_DATA lpFindFileData); 157 [System.Runtime.InteropServices.DllImport 158 ("kernel32.dll",CharSet = System.Runtime.InteropServices.CharSet.Auto,SetLastError = true)] 159 public static extern bool FindNextFile(int hndFindFile, ref WIN32_FIND_DATA lpFindFileData); 160 /// <summary> 161 /// 校验数字签名,360安全卫士模块 162 /// </summary> 163 /// <param name="FilePath"></param> 164 /// <returns>通过返回真,没通过返回假</returns> 165 [DllImport("360verify.dll")] 166 public static extern bool CheckFileTrustA(string FilePath); 167 } 168 public struct SECURITY_ATTRIBUTES 169 { 170 public int nLength; 171 public IntPtr lpSecurityDescriptor; 172 public bool bInheritHandle; 173 } 174 public enum wFunc 175 { 176 FO_MOVE = 0x0001, 177 FO_COPY = 0x0002, 178 FO_DELETE = 0x0003, 179 FO_RENAME = 0x0004 180 } 181 182 public enum FILEOP_FLAGS 183 { 184 FOF_MULTIDESTFILES = 0x0001, //pTo 指定了多个目标文件,而不是单个目录 185 FOF_CONFIRMMOUSE = 0x0002, 186 FOF_SILENT = 0x0044, // 不显示一个进度对话框 187 FOF_RENAMEONCOLLISION = 0x0008, // 碰到有抵触的名字时,自动分配前缀 188 FOF_NOCONFIRMATION = 0x10, // 不对用户显示提示 189 FOF_WANTMAPPINGHANDLE = 0x0020, // 填充 hNameMappings 字段,必须使用 SHFreeNameMappings 释放 190 FOF_ALLOWUNDO = 0x40, // 允许撤销 191 FOF_FILESONLY = 0x0080, // 使用 *.* 时, 只对文件操作 192 FOF_SIMPLEPROGRESS = 0x0100, // 简单进度条,意味者不显示文件名。 193 FOF_NOCONFIRMMKDIR = 0x0200, // 建新目录时不需要用户确定 194 FOF_NOERRORUI = 0x0400, // 不显示出错用户界面 195 FOF_NOCOPYSECURITYATTRIBS = 0x0800, // 不复制 NT 文件的安全属性 196 FOF_NORECURSION = 0x1000 // 不递归目录 197 } 198 199 public struct SHFILEOPSTRUCT 200 { 201 public int hWnd; //消息发送的窗口句柄; 202 public uint wFunc; //操作类型 203 public string pFrom; //源文件及路径 204 public string pTo; //目标文件及路径 205 public FILEOP_FLAGS fFlags; //操作与确认标志 206 public bool fAnyOperationsAborted; //操作选择位 207 public IntPtr hNameMappings; //文件映射 208 public string lpszProgressTitle; //文件操作进度窗口标题 209 } 210 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 211 public struct WIN32_FIND_DATA 212 { 213 public int dwFileAttributes;//文件属性 214 public FILETIME ftCreationTime; // 文件创建时间 215 public FILETIME ftLastAccessTime; // 文件最后一次访问时间 216 public FILETIME ftLastWriteTime; // 文件最后一次修改时间 217 public int nFileSizeHigh; // 文件长度高32位 218 public int nFileSizeLow; // 文件长度低32位 219 public int dwReserved0; // 系统保留 220 public int dwReserved1; // 系统保留 221 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] 222 public String cFileName; // 长文件名 223 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)] 224 public String cAlternateFileName; // 短文件名 225 } 226 public struct FILETIME 227 { 228 public int dwLowDateTime; 229 public int dwHighDateTime; 230 } 231 //[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 232 //public struct FILE_INFO 233 //{ 234 // /// <summary> 235 // /// 文件的标题名 236 // /// </summary> 237 // [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] 238 // public String szFileTitle; //文件的标题名 239 // /// <summary> 240 // /// 文件的属性 241 // /// </summary> 242 // public int dwFileAttributes; //文件的属性 243 // /// <summary> 244 // /// 文件的创建时间 245 // /// </summary> 246 // public FILETIME ftCreationTime; //文件的创建时间 247 // /// <summary> 248 // /// 文件的最后访问时间 249 // /// </summary> 250 // public FILETIME ftLastAccessTime; //文件的最后访问时间 251 // /// <summary> 252 // /// 文件的最后修改时间 253 // /// </summary> 254 // public FILETIME ftLastWriteTime; //文件的最后修改时间 255 // /// <summary> 256 // /// 文件大小的高位双字 257 // /// </summary> 258 // public int nFileSizeHigh; //文件大小的高位双字 259 // /// <summary> 260 // /// 文件大小的低位双字 261 // /// </summary> 262 // public int nFileSizeLow; //文件大小的低位双字 263 // /// <summary> 264 // /// 保留,为0 265 // /// </summary> 266 // public int dwReserved0; //保留,为0 267 // /// <summary> 268 // /// 保留,为0 269 // /// </summary> 270 // public int dwReserved1; //保留,为0 271 272 //} 273 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 274 public struct MY_FILE_INFO 275 { 276 /// <summary> 277 /// 文件的标题名 278 /// </summary> 279 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] 280 public String szFileTitle; //文件的标题名 281 /// <summary> 282 /// 文件的属性 283 /// </summary> 284 public int dwFileAttributes; //文件的属性 285 /// <summary> 286 /// 文件的创建时间 287 /// </summary> 288 public FILETIME ftCreationTime; //文件的创建时间 289 /// <summary> 290 /// 文件的最后访问时间 291 /// </summary> 292 public FILETIME ftLastAccessTime; //文件的最后访问时间 293 /// <summary> 294 /// 文件的最后修改时间 295 /// </summary> 296 public FILETIME ftLastWriteTime; //文件的最后修改时间 297 /// <summary> 298 /// 文件大小的高位双字 299 /// </summary> 300 public int nFileSizeHigh; //文件大小的高位双字 301 /// <summary> 302 /// 文件大小的低位双字 303 /// </summary> 304 public int nFileSizeLow; //文件大小的低位双字 305 /// <summary> 306 /// 文件路径 307 /// </summary> 308 public string FilePath; 309 /// <summary> 310 /// 短文件名 311 /// </summary> 312 public String cAlternateFileName; // 格式文件名 313 314 } 315 public class MyFindfile 316 { 317 /// <summary> 318 /// 判断文件是否存在 319 /// </summary> 320 /// <param name="Path"></param> 321 /// <returns></returns> 322 public static bool ExistsFileOrDir(string Path) 323 { 324 WIN32_FIND_DATA fd = new WIN32_FIND_DATA(); 325 bool k = false; 326 int f =fileinfo.FindFirstFile(Path,ref fd); 327 if ( f!= fileinfo.INVALID_HANDLE_VALUE) 328 { 329 fileinfo.FindClose(f); 330 k = true; 331 } 332 return k; 333 } 334 public static long ToLong(int height, int low) 335 { 336 long v = (uint)height; 337 v = v << 32; 338 v = v | ((uint)low); 339 return v; 340 } 341 public static void NcDelete(string path) 342 { 343 fileinfo.SetFileAttributes(path + "\\",fileinfo.FILE_ATTRIBUTE_NORMAL); 344 //fileinfo.RemoveDirectory(path + "\\"); 345 foreach (string s in MyFindfile.GetFilepath(path)) 346 { 347 fileinfo.SetFileAttributes(s, 128); 348 fileinfo.DeleteFile(s); 349 } 350 foreach (string p in MyFindfile.GetDirectories(path)) 351 { 352 NcDelete(path + "\\" + p); 353 } 354 fileinfo.RemoveDirectory(path + "\\"); 355 return; 356 } 357 //public static int Delete(string path) 358 //{ 359 // int n = 0; 360 // SHFILEOPSTRUCT lpFileOp = new SHFILEOPSTRUCT(); 361 // lpFileOp.wFunc = (uint)wFunc.FO_DELETE; 362 // lpFileOp.pFrom = path + "\0"; 363 // lpFileOp.fFlags = FILEOP_FLAGS.FOF_NOCONFIRMATION | FILEOP_FLAGS.FOF_NOERRORUI | FILEOP_FLAGS.FOF_SILENT; 364 // lpFileOp.fFlags &= ~FILEOP_FLAGS.FOF_ALLOWUNDO; 365 // lpFileOp.fAnyOperationsAborted = false; 366 // n = fileinfo.SHFileOperation(ref lpFileOp); 367 // if ((path.ToLower().EndsWith(".av") && n.ToString("X") == "402")) return 0; 368 369 // return n; 370 371 //} 372 /// <summary> 373 /// 创建时间 374 /// </summary> 375 public static System.DateTime CreationTime(FILETIME myData) 376 { 377 long time = ToLong(myData.dwHighDateTime, myData.dwLowDateTime);//获取文件时间。就是一个64位数 378 System.DateTime dtm = System.DateTime.FromFileTimeUtc(time); 379 return dtm.ToLocalTime();//转换为本地时间,并返回 380 } 381 /// <summary> 382 /// 当前对象最后访问时间 383 /// </summary> 384 public System.DateTime LastAccessTime(MY_FILE_INFO myData) 385 { 386 long time = ToLong(myData.ftLastAccessTime.dwHighDateTime, myData.ftLastAccessTime.dwLowDateTime); 387 System.DateTime dtm = System.DateTime.FromFileTimeUtc(time); 388 return dtm.ToLocalTime(); 389 } 390 /// <summary> 391 /// 当前对象最后保存时间 392 /// </summary> 393 public System.DateTime LastWriteTime(MY_FILE_INFO myData) 394 { 395 long time = ToLong(myData.ftLastWriteTime.dwHighDateTime, myData.ftLastWriteTime.dwLowDateTime); 396 System.DateTime dtm = System.DateTime.FromFileTimeUtc(time); 397 return dtm.ToLocalTime(); 398 } 399 /// <summary> 400 /// 当前文件长度,若为当前对象为文件则返回文件长度 401 /// </summary> 402 public static long FileLength(MY_FILE_INFO myData) 403 { 404 405 return ToLong(myData.nFileSizeHigh, myData.nFileSizeLow);//合并高位和低位,并返回 406 } 407 /// <summary> 408 /// 获取文件夹创建时间 409 /// </summary> 410 /// <param name="path"></param> 411 /// <returns></returns> 412 public static string GetDirCreationTime(string path) 413 { 414 path = path.Replace(@"\\","\\"); 415 return Directory.GetCreationTime(path).ToString(); 416 } 417 /// <summary> 418 /// 获取文件夹属性 419 /// </summary> 420 /// <param name="path"></param> 421 /// <returns></returns> 422 public static string GetDirAttributes(string path) 423 { 424 path = path.Replace(@"\\", "\\"); 425 int handle =-1; 426 string sx = ""; 427 WIN32_FIND_DATA fd = new WIN32_FIND_DATA(); 428 handle = fileinfo.FindFirstFile(path,ref fd); 429 if (handle != fileinfo.INVALID_FILE_ATTRIBUTES) 430 { 431 if ((fd.dwFileAttributes & fileinfo.FILE_ATTRIBUTE_HIDDEN) != 0) 432 { 433 sx = " 隐藏"; 434 } 435 436 if ((fd.dwFileAttributes & fileinfo.FILE_ATTRIBUTE_ARCHIVE) != 0) 437 { 438 sx += " 存档"; 439 } 440 if ((fd.dwFileAttributes & fileinfo.FILE_ATTRIBUTE_SYSTEM) != 0) 441 { 442 sx += " 系统"; 443 } 444 if ((fd.dwFileAttributes & fileinfo.FILE_ATTRIBUTE_READONLY) != 0) 445 { 446 sx += " 只读"; 447 } 448 fileinfo.FindClose(handle); 449 } 450 if (sx == "") 451 { 452 return " 常规"; 453 } 454 return sx; 455 } 456 /// <summary> 457 /// 获取文件属性 458 /// </summary> 459 /// <param name="FileAttributes"></param> 460 /// <returns></returns> 461 public static string GetFileAttributes(int FileAttributes) 462 { 463 string sx = ""; 464 if ((FileAttributes & fileinfo.FILE_ATTRIBUTE_HIDDEN) != 0) 465 { 466 sx = " 隐藏"; 467 } 468 if ((FileAttributes & fileinfo.FILE_ATTRIBUTE_ARCHIVE) != 0) 469 { 470 sx += " 存档"; 471 } 472 if ((FileAttributes & fileinfo.FILE_ATTRIBUTE_SYSTEM) != 0) 473 { 474 sx += " 系统"; 475 } 476 if ((FileAttributes & fileinfo.FILE_ATTRIBUTE_READONLY) != 0) 477 { 478 sx += " 只读"; 479 } 480 return sx; 481 } 482 /// <summary> 483 /// 获取指定目录下的文件 484 /// </summary> 485 /// <param name="path1"></param> 486 /// <returns></returns> 487 public static string[] GetFilepath(string path1) 488 { 489 List<string> str = new List<string>(); 490 if (path1.EndsWith("\\")) 491 { 492 path1 = path1.Remove(path1.Length - 1, 1); 493 } 494 path1 = path1 + "\\*.*"; 495 WIN32_FIND_DATA fd = new WIN32_FIND_DATA(); 496 int hSearch = -1; 497 hSearch = fileinfo.FindFirstFile(path1, ref fd); 498 if (hSearch != -1) 499 { 500 do 501 { 502 if ((fd.dwFileAttributes & fileinfo.FILE_ATTRIBUTE_DIRECTORY) == 0) 503 { 504 if (fd.cFileName != ".." && fd.cFileName != ".") 505 { 506 507 508 str.Add(path1.Replace("*.*",fd.cFileName)); 509 510 } 511 } 512 } 513 while (fileinfo.FindNextFile(hSearch, ref fd)); 514 fileinfo.FindClose(hSearch); 515 } 516 return str.ToArray(); 517 } 518 public static string[] GetDirectories(string path1) 519 { 520 int os =System.Environment.OSVersion.Version.Major;//系统版本号值(对畸形目录处理,不同系统,处理不同) 521 List<string> str = new List<string>(); 522 if (path1.EndsWith("\\")) 523 { 524 path1 = path1.Remove(path1.Length - 1, 1); 525 } 526 527 path1 = path1 + "\\*.*"; 528 WIN32_FIND_DATA fd = new WIN32_FIND_DATA(); 529 int hSearch = -1; 530 hSearch = fileinfo.FindFirstFile(path1, ref fd); 531 if (hSearch != -1) 532 { 533 do 534 { 535 if ((fd.dwFileAttributes & fileinfo.FILE_ATTRIBUTE_DIRECTORY) != 0) 536 { 537 if (fd.cFileName != ".." && fd.cFileName != ".") 538 { 539 if (fd.cFileName.EndsWith(".") && os< 6) 540 { 541 str.Add(fd.cFileName + "."); 542 } 543 else 544 { 545 str.Add(fd.cFileName); 546 } 547 } 548 } 549 } 550 while (fileinfo.FindNextFile(hSearch, ref fd)); 551 fileinfo.FindClose(hSearch); 552 } 553 return str.ToArray(); 554 } 555 /// <summary> 556 /// 获取文件,信息保存到MY_FILE_INFO结构体数组里 557 /// </summary> 558 /// <param name="path1"></param> 559 /// <param name="myfile"></param> 560 public static void Findfile(string path1,out MY_FILE_INFO[] myfile) 561 { 562 //List<FILE_INFO> filelist = new List<FILE_INFO>(); 563 if (path1[path1.Length - 1] == '\\') 564 { 565 path1.Remove(path1.Length - 1, 0); 566 } 567 string fpath = ""; 568 569 fpath = path1 + "\\" + "*.*"; 570 WIN32_FIND_DATA fd = new WIN32_FIND_DATA(); 571 int hSearch = -1; 572 //FILE_INFO fin = new FILE_INFO(); 573 List<MY_FILE_INFO> ml = new List<MY_FILE_INFO>(); 574 MY_FILE_INFO mf = new MY_FILE_INFO(); 575 hSearch = fileinfo.FindFirstFile(fpath, ref fd); 576 if (hSearch != fileinfo.INVALID_FILE_ATTRIBUTES) 577 { 578 do 579 { 580 if ((fd.dwFileAttributes & fileinfo.FILE_ATTRIBUTE_DIRECTORY) == 0) 581 { 582 if (fd.cFileName.ToString() != "." && fd.cFileName.ToString() != "..") 583 { 584 mf.dwFileAttributes = fd.dwFileAttributes;//属性 585 mf.szFileTitle = fd.cFileName;//文件名 586 mf.nFileSizeHigh = fd.nFileSizeHigh;//文件长度高位 587 mf.nFileSizeLow = fd.nFileSizeLow;//文件长度低位 588 mf.ftCreationTime = fd.ftCreationTime;//创建时间 589 mf.ftLastAccessTime = fd.ftLastAccessTime; 590 mf.ftLastWriteTime = fd.ftLastWriteTime; 591 mf.FilePath = fpath.Replace("*.*", fd.cFileName).Replace(@"\\", @"\"); 592 mf.cAlternateFileName = fd.cAlternateFileName; 593 ml.Add(mf); 594 } 595 } 596 } 597 while (fileinfo.FindNextFile(hSearch, ref fd)); 598 fileinfo.FindClose(hSearch); 599 600 } 601 myfile = ml.ToArray(); 602 603 } 604 } 605 606 }