Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Create() [2/2]

static FileStream System.IO.FileSystemAclExtensions.Create ( this FileInfo fileInfo,
FileMode mode,
FileSystemRights rights,
FileShare share,
int bufferSize,
FileOptions options,
FileSecurity fileSecurity )
inlinestatic

Definition at line 114 of file FileSystemAclExtensions.cs.

115 {
116 if (fileInfo == null)
117 {
118 throw new ArgumentNullException("fileInfo");
119 }
120 if (fileSecurity == null)
121 {
122 throw new ArgumentNullException("fileSecurity");
123 }
124 FileShare fileShare = share & ~FileShare.Inheritable;
125 if (mode < FileMode.CreateNew || mode > FileMode.Append)
126 {
127 throw new ArgumentOutOfRangeException("mode", System.SR.ArgumentOutOfRange_Enum);
128 }
129 if ((fileShare < FileShare.None) || fileShare > (FileShare.ReadWrite | FileShare.Delete))
130 {
131 throw new ArgumentOutOfRangeException("share", System.SR.ArgumentOutOfRange_Enum);
132 }
133 if (bufferSize <= 0)
134 {
135 throw new ArgumentOutOfRangeException("bufferSize", System.SR.ArgumentOutOfRange_NeedPosNum);
136 }
137 if ((rights & FileSystemRights.Write) == 0 && (mode == FileMode.Truncate || mode == FileMode.CreateNew || mode == FileMode.Create || mode == FileMode.Append))
138 {
140 }
141 SafeFileHandle safeFileHandle = CreateFileHandle(fileInfo.FullName, mode, rights, share, options, fileSecurity);
142 try
143 {
144 return new FileStream(safeFileHandle, GetFileStreamFileAccess(rights), bufferSize, (options & FileOptions.Asynchronous) != 0);
145 }
146 catch
147 {
148 safeFileHandle.Dispose();
149 throw;
150 }
151 }
static unsafe SafeFileHandle CreateFileHandle(string fullPath, FileMode mode, FileSystemRights rights, FileShare share, FileOptions options, FileSecurity security)
static FileAccess GetFileStreamFileAccess(FileSystemRights rights)
static string Argument_InvalidFileModeAndFileSystemRightsCombo
Definition SR.cs:58
static string ArgumentOutOfRange_NeedPosNum
Definition SR.cs:20
static string ArgumentOutOfRange_Enum
Definition SR.cs:18
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7

References System.SR.Argument_InvalidFileModeAndFileSystemRightsCombo, System.SR.ArgumentOutOfRange_Enum, System.SR.ArgumentOutOfRange_NeedPosNum, System.IO.FileSystemAclExtensions.CreateFileHandle(), System.Runtime.InteropServices.SafeHandle.Dispose(), System.SR.Format(), System.IO.FileSystemInfo.FullName, System.IO.FileSystemAclExtensions.GetFileStreamFileAccess(), and System.options.