Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

90 Zeilen
5.7 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.IO;
  22. using System.Security;
  23. using System.Security.AccessControl;
  24. namespace Alphaleonis.Win32.Filesystem
  25. {
  26. partial class FileInfo
  27. {
  28. #region .NET
  29. /// <summary>Opens a file in the specified mode.</summary>
  30. /// <returns>A <see cref="FileStream"/> file opened in the specified mode, with read/write access and unshared.</returns>
  31. /// <param name="mode">A <see cref="FileMode"/> constant specifying the mode (for example, Open or Append) in which to open the file.</param>
  32. [SecurityCritical]
  33. public FileStream Open(FileMode mode)
  34. {
  35. return File.OpenCore(Transaction, LongFullName, mode, FileAccess.Read, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath);
  36. }
  37. /// <summary>Opens a file in the specified mode with read, write, or read/write access.</summary>
  38. /// <returns>A <see cref="FileStream"/> object opened in the specified mode and access, and unshared.</returns>
  39. /// <param name="mode">A <see cref="FileMode"/> constant specifying the mode (for example, Open or Append) in which to open the file.</param>
  40. /// <param name="access">A <see cref="FileAccess"/> constant specifying whether to open the file with Read, Write, or ReadWrite file access.</param>
  41. [SecurityCritical]
  42. public FileStream Open(FileMode mode, FileAccess access)
  43. {
  44. return File.OpenCore(Transaction, LongFullName, mode, access, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath);
  45. }
  46. /// <summary>Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.</summary>
  47. /// <returns>A <see cref="FileStream"/> object opened with the specified mode, access, and sharing options.</returns>
  48. /// <param name="mode">A <see cref="FileMode"/> constant specifying the mode (for example, Open or Append) in which to open the file.</param>
  49. /// <param name="access">A <see cref="FileAccess"/> constant specifying whether to open the file with Read, Write, or ReadWrite file access.</param>
  50. /// <param name="share">A <see cref="FileShare"/> constant specifying the type of access other <see cref="FileStream"/> objects have to this file.</param>
  51. [SecurityCritical]
  52. public FileStream Open(FileMode mode, FileAccess access, FileShare share)
  53. {
  54. return File.OpenCore(Transaction, LongFullName, mode, access, share, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath);
  55. }
  56. #endregion // .NET
  57. #region AlphaFS
  58. /// <summary>[AlphaFS] Opens a file in the specified mode with read, write, or read/write access.</summary>
  59. /// <returns>A <see cref="FileStream"/> object opened in the specified mode and access, and unshared.</returns>
  60. /// <param name="mode">A <see cref="FileMode"/> constant specifying the mode (for example, Open or Append) in which to open the file.</param>
  61. /// <param name="rights">A <see cref="FileSystemRights"/> value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten along with additional options.</param>
  62. [SecurityCritical]
  63. public FileStream Open(FileMode mode, FileSystemRights rights)
  64. {
  65. return File.OpenCore(Transaction, LongFullName, mode, rights, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath);
  66. }
  67. /// <summary>[AlphaFS] Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.</summary>
  68. /// <returns>A <see cref="FileStream"/> object opened with the specified mode, access, and sharing options.</returns>
  69. /// <param name="mode">A <see cref="FileMode"/> constant specifying the mode (for example, Open or Append) in which to open the file.</param>
  70. /// <param name="rights">A <see cref="FileSystemRights"/> value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten along with additional options.</param>
  71. /// <param name="share">A <see cref="FileShare"/> constant specifying the type of access other <see cref="FileStream"/> objects have to this file.</param>
  72. [SecurityCritical]
  73. public FileStream Open(FileMode mode, FileSystemRights rights, FileShare share)
  74. {
  75. return File.OpenCore(Transaction, LongFullName, mode, rights, share, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath);
  76. }
  77. #endregion // AlphaFS
  78. }
  79. }