You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DirectoryInfo.Create.cs 3.7 KiB

8 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.Diagnostics.CodeAnalysis;
  22. using System.Security;
  23. using System.Security.AccessControl;
  24. namespace Alphaleonis.Win32.Filesystem
  25. {
  26. partial class DirectoryInfo
  27. {
  28. #region .NET
  29. /// <summary>Creates a directory.</summary>
  30. /// <remarks>If the directory already exists, this method does nothing.</remarks>
  31. [SecurityCritical]
  32. public void Create()
  33. {
  34. Directory.CreateDirectoryCore(Transaction, LongFullName, null, null, false, PathFormat.LongFullPath);
  35. }
  36. /// <summary>Creates a directory using a <see cref="System.Security.AccessControl.DirectorySecurity"/> object.</summary>
  37. /// <param name="directorySecurity">The access control to apply to the directory.</param>
  38. /// <remarks>If the directory already exists, this method does nothing.</remarks>
  39. [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
  40. [SecurityCritical]
  41. public void Create(DirectorySecurity directorySecurity)
  42. {
  43. Directory.CreateDirectoryCore(Transaction, LongFullName, null, directorySecurity, false, PathFormat.LongFullPath);
  44. }
  45. #endregion // .NET
  46. #region AlphaFS
  47. /// <summary>[AlphaFS] Creates a directory using a <see cref="System.Security.AccessControl.DirectorySecurity"/> object.</summary>
  48. /// <param name="compress">When <see langword="true"/> compresses the directory.</param>
  49. /// <remarks>If the directory already exists, this method does nothing.</remarks>
  50. [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
  51. [SecurityCritical]
  52. public void Create(bool compress)
  53. {
  54. Directory.CreateDirectoryCore(Transaction, LongFullName, null, null, compress, PathFormat.LongFullPath);
  55. }
  56. /// <summary>[AlphaFS] Creates a directory using a <see cref="System.Security.AccessControl.DirectorySecurity"/> object.</summary>
  57. /// <param name="directorySecurity">The access control to apply to the directory.</param>
  58. /// <param name="compress">When <see langword="true"/> compresses the directory.</param>
  59. /// <remarks>If the directory already exists, this method does nothing.</remarks>
  60. [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
  61. [SecurityCritical]
  62. public void Create(DirectorySecurity directorySecurity, bool compress)
  63. {
  64. Directory.CreateDirectoryCore(Transaction, LongFullName, null, directorySecurity, compress, PathFormat.LongFullPath);
  65. }
  66. #endregion // AlphaFS
  67. }
  68. }