25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

125 satır
7.0 KiB

  1. /* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. using System;
  22. using System.Security;
  23. namespace Alphaleonis.Win32.Filesystem
  24. {
  25. partial class Directory
  26. {
  27. #region .NET
  28. /// <summary>Gets the creation date and time of the specified directory.</summary>
  29. /// <returns>A <see cref="System.DateTime"/> structure set to the creation date and time for the specified directory. This value is expressed in local time.</returns>
  30. /// <param name="path">The directory for which to obtain creation date and time information.</param>
  31. [SecurityCritical]
  32. public static DateTime GetCreationTime(string path)
  33. {
  34. return File.GetCreationTimeCore(null, path, false, PathFormat.RelativePath).ToLocalTime();
  35. }
  36. /// <summary>Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  37. /// <returns>A <see cref="System.DateTime"/> structure set to the creation date and time for the specified directory. This value is expressed in UTC time.</returns>
  38. /// <param name="path">The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format.</param>
  39. [SecurityCritical]
  40. public static DateTime GetCreationTimeUtc(string path)
  41. {
  42. return File.GetCreationTimeCore(null, path, true, PathFormat.RelativePath);
  43. }
  44. #endregion // .NET
  45. /// <summary>[AlphaFS] Gets the creation date and time of the specified directory.</summary>
  46. /// <returns>A <see cref="System.DateTime"/> structure set to the creation date and time for the specified directory. This value is expressed in local time.</returns>
  47. /// <param name="path">The directory for which to obtain creation date and time information.</param>
  48. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  49. [SecurityCritical]
  50. public static DateTime GetCreationTime(string path, PathFormat pathFormat)
  51. {
  52. return File.GetCreationTimeCore(null, path, false, pathFormat).ToLocalTime();
  53. }
  54. /// <summary>[AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  55. /// <returns>A <see cref="System.DateTime"/> structure set to the creation date and time for the specified directory. This value is expressed in UTC time.</returns>
  56. /// <param name="path">The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format.</param>
  57. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  58. [SecurityCritical]
  59. public static DateTime GetCreationTimeUtc(string path, PathFormat pathFormat)
  60. {
  61. return File.GetCreationTimeCore(null, path, true, pathFormat);
  62. }
  63. #region Transactional
  64. /// <summary>[AlphaFS] Gets the creation date and time of the specified directory.</summary>
  65. /// <returns>A <see cref="System.DateTime"/> structure set to the creation date and time for the specified directory. This value is expressed in local time.</returns>
  66. /// <param name="transaction">The transaction.</param>
  67. /// <param name="path">The directory for which to obtain creation date and time information.</param>
  68. [SecurityCritical]
  69. public static DateTime GetCreationTimeTransacted(KernelTransaction transaction, string path)
  70. {
  71. return File.GetCreationTimeCore(transaction, path, false, PathFormat.RelativePath).ToLocalTime();
  72. }
  73. /// <summary>[AlphaFS] Gets the creation date and time of the specified directory.</summary>
  74. /// <returns>A <see cref="System.DateTime"/> structure set to the creation date and time for the specified directory. This value is expressed in local time.</returns>
  75. /// <param name="transaction">The transaction.</param>
  76. /// <param name="path">The directory for which to obtain creation date and time information.</param>
  77. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  78. [SecurityCritical]
  79. public static DateTime GetCreationTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
  80. {
  81. return File.GetCreationTimeCore(transaction, path, false, pathFormat).ToLocalTime();
  82. }
  83. /// <summary>[AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  84. /// <returns>A <see cref="System.DateTime"/> structure set to the creation date and time for the specified directory. This value is expressed in UTC time.</returns>
  85. /// <param name="transaction">The transaction.</param>
  86. /// <param name="path">The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format.</param>
  87. [SecurityCritical]
  88. public static DateTime GetCreationTimeUtcTransacted(KernelTransaction transaction, string path)
  89. {
  90. return File.GetCreationTimeCore(transaction, path, true, PathFormat.RelativePath);
  91. }
  92. /// <summary>[AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  93. /// <returns>A <see cref="System.DateTime"/> structure set to the creation date and time for the specified directory. This value is expressed in UTC time.</returns>
  94. /// <param name="transaction">The transaction.</param>
  95. /// <param name="path">The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format.</param>
  96. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  97. [SecurityCritical]
  98. public static DateTime GetCreationTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
  99. {
  100. return File.GetCreationTimeCore(transaction, path, true, pathFormat);
  101. }
  102. #endregion // Transactional
  103. }
  104. }