You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Environment.SystemPageSize returns cached value
* we are no longer shipping MS.IO.Redist, so we can use Array.MaxLength directly
* we are no longer shipping MS.IO.Redist, there is no need for File to be partial
* we are no longer shipping MS.IO.Redist, there is no need for FileInfo to be partial
* there is no need for .Win32.cs and .Windows.cs file anymore
Copy file name to clipboardExpand all lines: src/libraries/System.Private.CoreLib/src/System/IO/File.cs
+219-5Lines changed: 219 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,9 @@ namespace System.IO
16
16
{
17
17
// Class for creating FileStream objects, and some basic file management
18
18
// routines such as Delete, etc.
19
-
publicstaticpartialclassFile
19
+
publicstaticclassFile
20
20
{
21
-
// Don't use Array.MaxLength. MS.IO.Redist targets .NET Framework.
22
-
privateconstintMaxByteArrayLength=0x7FFFFFC7;
21
+
privateconstintChunkSize=8192;
23
22
privatestaticEncoding?s_UTF8NoBOM;
24
23
25
24
// UTF-8 without BOM and with error detection. Same as the default encoding for StreamWriter.
@@ -121,6 +120,12 @@ public static bool Exists([NotNullWhen(true)] string? path)
121
120
returnfalse;
122
121
}
123
122
123
+
/// <summary>
124
+
/// Initializes a new instance of the <see cref="FileStream" /> class with the specified path, creation mode, read/write and sharing permission, the access other FileStreams can have to the same file, the buffer size, additional file options and the allocation size.
125
+
/// </summary>
126
+
/// <remarks><see cref="FileStream(string,System.IO.FileStreamOptions)"/> for information about exceptions.</remarks>
/// Initializes a new instance of the <see cref="Microsoft.Win32.SafeHandles.SafeFileHandle" /> class with the specified path, creation mode, read/write and sharing permission, the access other SafeFileHandles can have to the same file, additional file options and the allocation size.
140
+
/// </summary>
141
+
/// <param name="path">A relative or absolute path for the file that the current <see cref="Microsoft.Win32.SafeHandles.SafeFileHandle" /> instance will encapsulate.</param>
142
+
/// <param name="mode">One of the enumeration values that determines how to open or create the file. The default value is <see cref="FileMode.Open" /></param>
143
+
/// <param name="access">A bitwise combination of the enumeration values that determines how the file can be accessed. The default value is <see cref="FileAccess.Read" /></param>
144
+
/// <param name="share">A bitwise combination of the enumeration values that determines how the file will be shared by processes. The default value is <see cref="FileShare.Read" />.</param>
145
+
/// <param name="preallocationSize">The initial allocation size in bytes for the file. A positive value is effective only when a regular file is being created, overwritten, or replaced.
146
+
/// Negative values are not allowed. In other cases (including the default 0 value), it's ignored.</param>
147
+
/// <param name="options">An object that describes optional <see cref="Microsoft.Win32.SafeHandles.SafeFileHandle" /> parameters to use.</param>
148
+
/// <exception cref="T:System.ArgumentNullException"><paramref name="path" /> is <see langword="null" />.</exception>
149
+
/// <exception cref="T:System.ArgumentException"><paramref name="path" /> is an empty string (""), contains only white space, or contains one or more invalid characters.
150
+
/// -or-
151
+
/// <paramref name="path" /> refers to a non-file device, such as <c>CON:</c>, <c>COM1:</c>, <c>LPT1:</c>, etc. in an NTFS environment.</exception>
152
+
/// <exception cref="T:System.NotSupportedException"><paramref name="path" /> refers to a non-file device, such as <c>CON:</c>, <c>COM1:</c>, <c>LPT1:</c>, etc. in a non-NTFS environment.</exception>
153
+
/// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="preallocationSize" /> is negative.
154
+
/// -or-
155
+
/// <paramref name="mode" />, <paramref name="access" />, or <paramref name="share" /> contain an invalid value.</exception>
156
+
/// <exception cref="T:System.IO.FileNotFoundException">The file cannot be found, such as when <paramref name="mode" /> is <see cref="FileMode.Truncate" /> or <see cref="FileMode.Open" />, and the file specified by <paramref name="path" /> does not exist. The file must already exist in these modes.</exception>
157
+
/// <exception cref="T:System.IO.IOException">An I/O error, such as specifying <see cref="FileMode.CreateNew" /> when the file specified by <paramref name="path" /> already exists, occurred.
158
+
/// -or-
159
+
/// The disk was full (when <paramref name="preallocationSize" /> was provided and <paramref name="path" /> was pointing to a regular file).
160
+
/// -or-
161
+
/// The file was too large (when <paramref name="preallocationSize" /> was provided and <paramref name="path" /> was pointing to a regular file).</exception>
162
+
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
163
+
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception>
164
+
/// <exception cref="T:System.UnauthorizedAccessException">The <paramref name="access" /> requested is not permitted by the operating system for the specified <paramref name="path" />, such as when <paramref name="access" /> is <see cref="FileAccess.Write" /> or <see cref="FileAccess.ReadWrite" /> and the file or directory is set for read-only access.
165
+
/// -or-
166
+
/// <see cref="F:System.IO.FileOptions.Encrypted" /> is specified for <paramref name="options" />, but file encryption is not supported on the current platform.</exception>
167
+
/// <exception cref="T:System.IO.PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length. </exception>
0 commit comments