879 references to FileMode
aspire (8)
Aspire.Cli.Tests (1)
Aspire.Hosting (3)
Crossgen2Tasks (2)
csc (3)
CSharpSyntaxGenerator (2)
dotnet (18)
dotnet-aot (3)
dotnet-openapi (1)
dotnet-svcutil-lib (19)
FrameworkFork\Microsoft.CodeDom\Microsoft\CSharpCodeProvider.cs (5)
710Stream temp = new FileStream(responseFileName, FileMode.Create, FileAccess.Write, FileShare.Read);
3886new FileStream(options.OutputAssembly, FileMode.Create, FileAccess.ReadWrite).Dispose();
3954using (FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read, share))
4177Stream temp = new FileStream(filenames[i], FileMode.Create, FileAccess.Write, FileShare.Read);
4238Stream temp = new FileStream(name, FileMode.Create, FileAccess.Write, FileShare.Read);
dotnet-user-jwts (9)
GenerateDocumentationAndConfigFiles (3)
ILCompiler.Compiler (6)
ILCompiler.Diagnostics (1)
ILCompiler.ReadyToRun (5)
ILCompiler.RyuJit (1)
ILCompiler.TypeSystem (1)
illink (4)
ILLink.Tasks (1)
installer.tasks (1)
Microsoft.Arcade.Common (3)
Microsoft.AspNetCore.Http (1)
Microsoft.AspNetCore.InternalTesting (1)
Microsoft.AspNetCore.Mvc.Core (1)
Microsoft.AspNetCore.Server.HttpSys (1)
Microsoft.AspNetCore.Server.IntegrationTesting (1)
Microsoft.AspNetCore.WebUtilities (4)
FileBufferingWriteStream.cs (3)
202await using var readStream = new FileStream(FileStream.Name, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.ReadWrite, bufferSize: 1, useAsync: true);
228await using var readStream = new FileStream(FileStream.Name, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.ReadWrite, bufferSize: 1, useAsync: true);
281FileMode.Create,
Microsoft.Build (13)
Microsoft.Build.Framework (10)
FileUtilities.cs (5)
88using (new FileStream(pathWithUpperCase, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None, 0x1000, FileOptions.DeleteOnClose))
1605FileMode mode = append ? FileMode.Append : FileMode.Create;
1620Stream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.SequentialScan);
Microsoft.Build.Tasks.CodeAnalysis (3)
Microsoft.Build.Tasks.Core (34)
GenerateResource.cs (3)
3417WriteResources(reader, new PreserializedResourceWriter(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None))); // closes writer for us
3423WriteResources(reader, new ResourceWriter(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None))); // closes writer for us
3642using var fs = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
ManifestUtil\TrustInfo.cs (5)
435using (Stream s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
474using (Stream s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
552using (Stream s = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None))
661s = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
665s = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None);
Microsoft.Build.Tasks.Git (1)
Microsoft.Build.Utilities.Core (1)
Microsoft.CodeAnalysis (32)
CommandLine\CommonCompiler.cs (12)
209var peStream = FileSystem.OpenFileWithNormalizedException(path, FileMode.Open, FileAccess.Read, FileShare.Read);
388FileMode.Open,
722FileMode.Create,
1199var fileStream = OpenFile(path, diagnostics, FileMode.Create, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete);
1286FileMode.Open,
1372FileMode.OpenOrCreate,
1589var readStream = OpenFile(readFilesPath, diagnostics, mode: FileMode.OpenOrCreate);
1590var writtenStream = OpenFile(writtenFilesPath, diagnostics, mode: FileMode.OpenOrCreate);
1648FileMode mode = FileMode.Open,
1729return fileSystem.OpenFile(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
1836using var stream = fileSystem.OpenFile(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
FileSystem\ICommonCompilerFileSystem.cs (5)
18Stream OpenFile(string filePath, FileMode mode, FileAccess access, FileShare share);
20Stream OpenFileEx(string filePath, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, out string normalizedFilePath);
28internal static Stream OpenFileWithNormalizedException(this ICommonCompilerFileSystem fileSystem, string filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
63public Stream OpenFile(string filePath, FileMode mode, FileAccess access, FileShare share)
66public Stream OpenFileEx(string filePath, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, out string normalizedFilePath)
MetadataReference\MetadataReference.cs (3)
246StandardFileSystem.Instance.OpenFileWithNormalizedException(path, FileMode.Open, FileAccess.Read, FileShare.Read),
258StandardFileSystem.Instance.OpenFileWithNormalizedException(path, FileMode.Open, FileAccess.Read, FileShare.Read),
369var peStream = StandardFileSystem.Instance.OpenFileWithNormalizedException(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
Microsoft.CodeAnalysis.Analyzers (3)
Microsoft.CodeAnalysis.AnalyzerUtilities (3)
Microsoft.CodeAnalysis.CodeStyle (3)
Microsoft.CodeAnalysis.CSharp (1)
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Microsoft.CodeAnalysis.ExternalAccess.HotReload (2)
Microsoft.CodeAnalysis.Features (5)
Microsoft.CodeAnalysis.Razor.Compiler (1)
Microsoft.CodeAnalysis.ResxSourceGenerator (3)
Microsoft.CodeAnalysis.Scripting (2)
Microsoft.CodeAnalysis.Workspaces (7)
Microsoft.CodeAnalysis.Workspaces.MSBuild (1)
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (2)
Microsoft.Data.Analysis (3)
Microsoft.Data.Analysis.Tests (1)
Microsoft.Deployment.DotNet.Releases (4)
Product.cs (2)
185using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, useAsync: true);
226using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, useAsync: true);
Microsoft.DotNet.ApiCompatibility (2)
Microsoft.DotNet.Arcade.Sdk (3)
Microsoft.DotNet.Build.Manifest (1)
Microsoft.DotNet.Build.Tasks.Installers (2)
Microsoft.DotNet.Build.Tasks.Packaging (4)
Microsoft.DotNet.Build.Tasks.VisualStudio (4)
Microsoft.DotNet.Build.Tasks.Workloads (2)
Microsoft.DotNet.GenFacades (2)
Microsoft.DotNet.HotReload.Utils.Generator (1)
Microsoft.DotNet.HotReload.Watch (1)
Microsoft.DotNet.InternalAbstractions (2)
Microsoft.DotNet.NuGetRepack.Tasks (7)
Microsoft.DotNet.PackageTesting (2)
Microsoft.DotNet.ProjectTools (1)
Microsoft.DotNet.SharedFramework.Sdk (2)
Microsoft.DotNet.SourceBuild.Tasks (2)
Microsoft.DotNet.StrongName (4)
Microsoft.DotNet.XliffTasks (2)
Microsoft.Extensions.AI.Abstractions (4)
Contents\DataContent.cs (2)
149using FileStream fileStream = new(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1, useAsync: true);
237using FileStream fileStream = new(path, FileMode.CreateNew, FileAccess.Write, FileShare.None, 1, useAsync: true);
Microsoft.Extensions.AI.Abstractions.Tests (3)
parent\parent\parent\eng\MSBuild\parent\parent\src\LegacySupport\FilePolyfills\FilePolyfills.cs (2)
32using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, useAsync: true);
75using var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true);
Microsoft.Extensions.AI.Evaluation.Reporting (4)
Microsoft.Extensions.Configuration.FileExtensions (1)
Microsoft.Extensions.DataIngestion.Abstractions (1)
Microsoft.Extensions.DataIngestion.Markdig (1)
Microsoft.Extensions.DataIngestion.MarkItDown (1)
Microsoft.Extensions.DataIngestion.Tests (1)
Microsoft.Extensions.DependencyModel (2)
Microsoft.Extensions.FileProviders.Embedded.Manifest.Task (1)
Microsoft.Extensions.FileProviders.Physical (1)
Microsoft.Extensions.ML (2)
Microsoft.Maui.Graphics (2)
Microsoft.ML.AutoML (3)
Microsoft.ML.Core (8)
Microsoft.ML.Core.Tests (1)
Microsoft.ML.Data (2)
Microsoft.ML.FastTree (1)
Microsoft.ML.ImageAnalytics (2)
Microsoft.ML.Maml (1)
Microsoft.ML.OnnxTransformer (3)
Microsoft.ML.PerformanceTests (3)
Microsoft.ML.ResultProcessor (1)
Microsoft.ML.Samples (8)
Microsoft.ML.Samples.GPU (5)
Microsoft.ML.SamplesUtils (1)
Microsoft.ML.TensorFlow (2)
Microsoft.ML.TestFramework (3)
Microsoft.ML.TestFrameworkCommon (1)
Microsoft.ML.Tests (14)
ImagesTests.cs (4)
1235using FileStream imageStream = new FileStream(dataFile, FileMode.Open, FileAccess.Read, FileShare.Read);
1336FileStream stream = new FileStream(imageFile, FileMode.Open, FileAccess.Read, FileShare.Read);
1343stream = new FileStream(imageFile, FileMode.Open, FileAccess.Read, FileShare.None);
1352stream = new FileStream(imageFile, FileMode.Open, FileAccess.Read, FileShare.Read);
Microsoft.ML.Vision (8)
Microsoft.NET.Build.Containers (1)
Microsoft.NET.Build.Extensions.Tasks (3)
Microsoft.NET.Build.Tasks (9)
Microsoft.NET.HostModel (7)
Microsoft.NET.Sdk.BlazorWebAssembly.Tool (1)
Microsoft.NET.Sdk.Publish.Tasks (2)
Microsoft.NET.Sdk.Razor.Tasks (1)
Microsoft.NET.Sdk.StaticWebAssets.Tool (1)
Microsoft.TemplateEngine.Utils (1)
Microsoft.TestPlatform.CoreUtilities (10)
Microsoft.TestPlatform.CrossPlatEngine (2)
Microsoft.TestPlatform.Extensions.BlameDataCollector (3)
Microsoft.TestPlatform.PlatformAbstractions (2)
Microsoft.TestPlatform.TestHostRuntimeProvider (4)
Microsoft.VisualBasic.Core (16)
Microsoft\VisualBasic\CompilerServices\VB6File.vb (2)
405m_file = New FileStream(m_sFullPath, FileMode.Open, CType(m_access, FileAccess), CType(m_share, FileShare))
407m_file = New FileStream(m_sFullPath, FileMode.Create, CType(m_access, FileAccess), CType(m_share, FileShare))
Microsoft\VisualBasic\CompilerServices\VB6OutputFile.vb (3)
43m_file = New FileStream(m_sFullPath, FileMode.Open, CType(m_access, FileAccess), CType(m_share, FileShare))
45m_file = New FileStream(m_sFullPath, FileMode.Create, CType(m_access, FileAccess), CType(m_share, FileShare))
48m_file = New FileStream(m_sFullPath, FileMode.Create, CType(m_access, FileAccess), CType(m_share, FileShare))
Microsoft.VisualStudio.TestPlatform.Common (2)
Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger (2)
Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger (2)
Microsoft.VisualStudio.TestPlatform.ObjectModel (4)
Mono.Cecil (6)
Mono.Cecil.Mdb (4)
MSBuild (1)
mscorlib (1)
netstandard (1)
NuGet.Commands (4)
NuGet.Common (3)
NuGet.PackageManagement (2)
NuGet.Packaging (7)
NuGet.ProjectModel (5)
NuGet.Protocol (18)
PresentationBuildTasks (5)
PresentationCore (9)
PresentationFramework (17)
PresentationUI (20)
ReachFramework (19)
Roslyn.Diagnostics.Analyzers (3)
rzc (5)
sdk-tasks (3)
System.CodeDom (7)
System.ComponentModel.TypeConverter (1)
System.Configuration.ConfigurationManager (6)
System.Data.Common (1)
System.Data.OleDb (2)
System.Diagnostics.Process (2)
System.Diagnostics.StackTrace (1)
System.Drawing.Common (1)
System.Formats.Tar (6)
System.IO.Compression.ZipFile (7)
System\IO\Compression\ZipFile.Create.cs (4)
514(FileMode fileMode, FileAccess access, FileShare fileShare) = mode switch
516ZipArchiveMode.Read => (FileMode.Open, FileAccess.Read, FileShare.Read),
517ZipArchiveMode.Create => (FileMode.CreateNew, FileAccess.Write, FileShare.None),
518ZipArchiveMode.Update => (FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None),
System.IO.FileSystem.AccessControl (18)
_generated\0\LibraryImports.g.cs (2)
7private static unsafe partial global::Microsoft.Win32.SafeHandles.SafeFileHandle CreateFilePrivate(string lpFileName, int dwDesiredAccess, global::System.IO.FileShare dwShareMode, global::Interop.Kernel32.SECURITY_ATTRIBUTES* lpSecurityAttributes, global::System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, nint hTemplateFile)
47static extern unsafe nint __PInvoke(ushort* __lpFileName_native, int __dwDesiredAccess_native, global::System.IO.FileShare __dwShareMode_native, global::Interop.Kernel32.SECURITY_ATTRIBUTES* __lpSecurityAttributes_native, global::System.IO.FileMode __dwCreationDisposition_native, int __dwFlagsAndAttributes_native, nint __hTemplateFile_native);
System\IO\FileSystemAclExtensions.cs (13)
134public static FileStream Create(this FileInfo fileInfo, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, FileSecurity? fileSecurity)
141if (mode < FileMode.CreateNew || mode > FileMode.Append)
159(mode == FileMode.Truncate || mode == FileMode.CreateNew || mode == FileMode.Create || mode == FileMode.Append))
166if ((rights & FileSystemRights.ReadAndExecute) != 0 && mode == FileMode.Append)
173if (mode == FileMode.Truncate && (rights & FileSystemRights.Write) != FileSystemRights.Write)
255private static unsafe SafeFileHandle CreateFileHandle(string fullPath, FileMode mode, FileSystemRights rights, FileShare share, FileOptions options, FileSecurity? security)
260if (mode == FileMode.Append)
262mode = FileMode.OpenOrCreate;
289static SafeFileHandle CreateFileHandleInternal(string fullPath, FileMode mode, FileSystemRights rights, FileShare share, int flagsAndAttributes, Interop.Kernel32.SECURITY_ATTRIBUTES* secAttrs)
System.IO.FileSystem.Primitives (1)
System.IO.IsolatedStorage (21)
System\IO\IsolatedStorage\IsolatedStorageFile.cs (4)
211public IsolatedStorageFileStream OpenFile(string path, FileMode mode)
217public IsolatedStorageFileStream OpenFile(string path, FileMode mode, FileAccess access)
223public IsolatedStorageFileStream OpenFile(string path, FileMode mode, FileAccess access, FileShare share)
232return new IsolatedStorageFileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, this);
System\IO\IsolatedStorage\IsolatedStorageFileStream.cs (17)
21public IsolatedStorageFileStream(string path, FileMode mode)
22: this(path, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.None, null)
26public IsolatedStorageFileStream(string path, FileMode mode, IsolatedStorageFile? isf)
27: this(path, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.None, isf)
31public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access)
36public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, IsolatedStorageFile? isf)
41public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, FileShare share)
46public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile? isf)
51public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
56public IsolatedStorageFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile? isf)
84private static InitializationData InitializeFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile? isf)
104case FileMode.CreateNew: // Assume new file
105case FileMode.Create: // Check for New file & Unreserve
106case FileMode.OpenOrCreate: // Check for new file
107case FileMode.Truncate: // Unreserve old file size
108case FileMode.Append: // Check for new file
109case FileMode.Open: // Open existing, else exception
System.IO.MemoryMappedFiles (12)
System\IO\MemoryMappedFiles\MemoryMappedFile.cs (11)
89return CreateFromFile(path, FileMode.Open, null, DefaultSize, MemoryMappedFileAccess.ReadWrite);
91public static MemoryMappedFile CreateFromFile(string path, FileMode mode)
96public static MemoryMappedFile CreateFromFile(string path, FileMode mode, string? mapName)
101public static MemoryMappedFile CreateFromFile(string path, FileMode mode, string? mapName, long capacity)
106public static MemoryMappedFile CreateFromFile(string path, FileMode mode, string? mapName, long capacity,
112if (mode == FileMode.Append)
116if (mode == FileMode.Truncate)
123FileMode.Open => true, // FileStream ctor will throw if the file doesn't exist
124FileMode.CreateNew => false,
129if (mode is not (FileMode.CreateNew or FileMode.Create)) // the file is brand new and it's empty
System.IO.Packaging (46)
System.Management (1)
System.Net.Mail (3)
System.Net.NetworkInformation (1)
System.Net.Quic (1)
System.Net.Requests (4)
System\Net\FileWebRequest.cs (3)
148_stream = new WebFileStream(this, _uri.LocalPath, FileMode.Create, FileAccess.Write, FileShare.Read);
314public WebFileStream(FileWebRequest request, string path, FileMode mode, FileAccess access, FileShare sharing) :
320public WebFileStream(FileWebRequest request, string path, FileMode mode, FileAccess access, FileShare sharing, int length, bool async) :
System.Net.Security (1)
System.Net.Sockets (2)
System.Net.WebClient (3)
System.Private.CoreLib (104)
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs (17)
227SafeFileHandle handle = Open(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read, options, preallocationSize: 0, DefaultCreateMode, out fileLength, out filePermissions, false, out _, null);
232internal static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode = null,
238internal static SafeFileHandle? OpenNoFollowSymlink(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, out bool wasSymlink, UnixFileMode? unixCreateMode = null,
244private static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode openPermissions,
292private static Interop.Sys.OpenFlags PreOpenConfigurationFromOptions(FileMode mode, FileAccess access, FileShare share, FileOptions options, bool failForSymlink)
303case FileMode.Open: // Open maps to the default behavior for open(...). No flags needed.
305case FileMode.Truncate:
314case FileMode.Append: // Append is the same as OpenOrCreate, except that we'll also separately jump to the end later
315case FileMode.OpenOrCreate:
319case FileMode.Create:
327case FileMode.CreateNew:
369private bool Init(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize,
436share == FileShare.None && mode == FileMode.OpenOrCreate)
478if ((mode == FileMode.Create || mode == FileMode.Truncate) && !DisableFileLocking)
506Debug.Assert(mode == FileMode.Create || mode == FileMode.CreateNew);
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\File.cs (36)
70=> new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize);
73=> new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, options);
126public static FileStream Open(string path, FileMode mode)
127=> Open(path, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.None);
129public static FileStream Open(string path, FileMode mode, FileAccess access)
132public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share)
139/// <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>
153/// <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>
154/// <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.
165public static SafeFileHandle OpenHandle(string path, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read,
196return SafeFileHandle.Open(NullDevicePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, FileOptions.None, preallocationSize: 0);
644=> new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
647=> new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
691WriteToFile(path, FileMode.Create, contents, encoding);
717WriteToFile(path, FileMode.Create, contents, encoding);
724using (SafeFileHandle sfh = OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.Read, options))
790using SafeFileHandle sfh = OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read);
840using SafeFileHandle fileHandle = OpenHandle(path, FileMode.Append, FileAccess.Write, FileShare.Read);
885using SafeFileHandle fileHandle = OpenHandle(path, FileMode.Append, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous);
1005WriteToFile(path, FileMode.Append, contents, encoding);
1035WriteToFile(path, FileMode.Append, contents, encoding);
1108new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultBufferSize, FileOptions.Asynchronous | FileOptions.SequentialScan),
1193return WriteToFileAsync(path, FileMode.Create, contents, encoding, cancellationToken);
1205SafeFileHandle sfh = OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.Read, options);
1316using SafeFileHandle sfh = OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous);
1372new FileStream(path, append ? FileMode.Append : FileMode.Create, FileAccess.Write, FileShare.Read, DefaultBufferSize, FileOptions.Asynchronous),
1434return WriteToFileAsync(path, FileMode.Append, contents, encoding, cancellationToken);
1557private static unsafe void WriteToFile(string path, FileMode mode, ReadOnlySpan<char> contents, Encoding encoding)
1563long fileOffset = mode == FileMode.Append && fileHandle.CanSeek ? RandomAccess.GetLength(fileHandle) : 0;
1613private static async Task WriteToFileAsync(string path, FileMode mode, ReadOnlyMemory<char> contents, Encoding encoding, CancellationToken cancellationToken)
1619long fileOffset = mode == FileMode.Append && fileHandle.CanSeek ? RandomAccess.GetLength(fileHandle) : 0;
1664private static long GetPreallocationSize(FileMode mode, ReadOnlySpan<char> contents, Encoding encoding, int preambleSize)
1673if (mode == FileMode.Append)
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\FileInfo.cs (6)
137public FileStream Open(FileMode mode)
138=> Open(mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.None);
140public FileStream Open(FileMode mode, FileAccess access)
143public FileStream Open(FileMode mode, FileAccess access, FileShare share)
152FileStream fileStream = new FileStream(NormalizedPath, FileMode.Open, FileAccess.Read, FileShare.Read, File.DefaultBufferSize, false);
159FileStream fileStream = new FileStream(NormalizedPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\FileStream.cs (15)
106public FileStream(string path, FileMode mode)
107: this(path, mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite, DefaultShare, DefaultBufferSize, DefaultIsAsync)
111public FileStream(string path, FileMode mode, FileAccess access)
116public FileStream(string path, FileMode mode, FileAccess access, FileShare share)
121public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
126public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync)
131public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options)
172if ((options.Access & FileAccess.Read) != 0 && options.Mode == FileMode.Append)
178if (options.Mode == FileMode.Truncate || options.Mode == FileMode.CreateNew || options.Mode == FileMode.Create || options.Mode == FileMode.Append)
192if (options.Mode == FileMode.Truncate || options.Mode == FileMode.Open)
204private FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize)
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\Strategies\FileStreamHelpers.cs (12)
30internal static FileStreamStrategy ChooseStrategy(FileStream fileStream, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode)
62internal static void ValidateArguments(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize)
70if (mode < FileMode.CreateNew || mode > FileMode.Append)
105if (mode == FileMode.Truncate || mode == FileMode.CreateNew || mode == FileMode.Create || mode == FileMode.Append)
112if ((access & FileAccess.Read) != 0 && mode == FileMode.Append)
125internal static void ValidateArgumentsForPreallocation(FileMode mode, FileAccess access)
135if (mode != FileMode.Create &&
136mode != FileMode.CreateNew)
System.Private.Xml (8)
System.Reflection.Emit (1)
System.Reflection.Metadata (1)
System.Reflection.MetadataLoadContext (2)
System.Resources.Extensions (2)
System.Resources.Writer (1)
System.Runtime (1)
System.Speech (5)
Synthesis\SpeechSynthesizer.cs (2)
192SetOutputStream(new FileStream(path, FileMode.Create, FileAccess.Write), null, true, true);
201SetOutputStream(new FileStream(path, FileMode.Create, FileAccess.Write), formatInfo, true, true);
System.Windows.Forms (5)
System.Windows.Forms.Design (4)
System.Windows.Forms.Primitives (1)
vbc (3)
VBCSCompiler (4)
vstest.console (4)
vstest.console.arm64 (4)