4337 references to File
AnalyzerRunner (4)
CodeRefactoringRunner.cs (1)
203if (File.Exists(path))
DiagnosticAnalyzerRunner.cs (3)
228File.WriteAllText(fileName, completeOutput.ToString(), Encoding.UTF8); 229File.WriteAllText(uniqueFileName, uniqueOutput.ToString(), Encoding.UTF8); 287if (File.Exists(path))
aspire (86)
Agents\ClaudeCode\ClaudeCodeAgentEnvironmentScanner.cs (10)
173if (!File.Exists(configFilePath)) 180var content = File.ReadAllText(configFilePath); 209if (!File.Exists(configFilePath)) 216var content = File.ReadAllText(configFilePath); 257if (File.Exists(configFilePath)) 259var existingContent = await File.ReadAllTextAsync(configFilePath, cancellationToken); 284await File.WriteAllTextAsync(configFilePath, jsonContent, cancellationToken); 298if (File.Exists(configFilePath)) 300var existingContent = await File.ReadAllTextAsync(configFilePath, cancellationToken); 325await File.WriteAllTextAsync(configFilePath, jsonContent, cancellationToken);
Agents\CommonAgentApplicators.cs (3)
27if (File.Exists(agentsFilePath)) 86if (!File.Exists(agentsFilePath)) 88await File.WriteAllTextAsync(agentsFilePath, AgentsMdContent, cancellationToken);
Agents\CopilotCli\CopilotCliAgentEnvironmentScanner.cs (10)
156if (!File.Exists(configFilePath)) 163var content = File.ReadAllText(configFilePath); 219if (File.Exists(configFilePath)) 221var existingContent = await File.ReadAllTextAsync(configFilePath, cancellationToken); 252await File.WriteAllTextAsync(configFilePath, jsonContent, cancellationToken); 274if (File.Exists(configFilePath)) 276var existingContent = await File.ReadAllTextAsync(configFilePath, cancellationToken); 303await File.WriteAllTextAsync(configFilePath, jsonContent, cancellationToken); 313if (!File.Exists(configFilePath)) 320var content = File.ReadAllText(configFilePath);
Agents\OpenCode\OpenCodeAgentEnvironmentScanner.cs (10)
44var configFileExists = File.Exists(configFilePath); 116var content = File.ReadAllText(configFilePath); 199if (File.Exists(configFilePath)) 201var existingContent = await File.ReadAllTextAsync(configFilePath, cancellationToken); 233await File.WriteAllTextAsync(configFilePath, jsonOutput, cancellationToken); 247if (File.Exists(configFilePath)) 249var existingContent = await File.ReadAllTextAsync(configFilePath, cancellationToken); 281await File.WriteAllTextAsync(configFilePath, jsonOutput, cancellationToken); 289if (!File.Exists(configFilePath)) 296var content = File.ReadAllText(configFilePath);
Agents\VsCode\VsCodeAgentEnvironmentScanner.cs (10)
199if (!File.Exists(mcpConfigPath)) 206var content = File.ReadAllText(mcpConfigPath); 235if (!File.Exists(mcpConfigPath)) 242var content = File.ReadAllText(mcpConfigPath); 290if (File.Exists(mcpConfigPath)) 292var existingContent = await File.ReadAllTextAsync(mcpConfigPath, cancellationToken); 318await File.WriteAllTextAsync(mcpConfigPath, jsonContent, cancellationToken); 338if (File.Exists(mcpConfigPath)) 340var existingContent = await File.ReadAllTextAsync(mcpConfigPath, cancellationToken); 366await File.WriteAllTextAsync(mcpConfigPath, jsonContent, cancellationToken);
Caching\DiskCache.cs (5)
69return await File.ReadAllTextAsync(cacheFilePath, cancellationToken).ConfigureAwait(false); 108await File.WriteAllTextAsync(tempFile, content, cancellationToken).ConfigureAwait(false); 110if (File.Exists(fullPath)) 114File.Delete(fullPath); 122File.Move(tempFile, fullPath);
Commands\RunCommand.cs (2)
220if (!File.Exists(runJsonFilePath)) 520if (!File.Exists(auxiliarySocketPath))
Commands\UpdateCommand.cs (11)
329if (!File.Exists(newExePath)) 337if (File.Exists(targetExePath)) 346File.Move(targetExePath, backupPath); 353File.Copy(newExePath, targetExePath, overwrite: true); 382if (File.Exists(backupPath)) 384if (File.Exists(targetExePath)) 386File.Delete(targetExePath); 388File.Move(backupPath, targetExePath); 443var mode = File.GetUnixFileMode(filePath); 445File.SetUnixFileMode(filePath, mode); 509File.Delete(backupFile);
Configuration\ConfigurationService.cs (8)
20if (File.Exists(settingsFilePath)) 22var existingContent = await File.ReadAllTextAsync(settingsFilePath, cancellationToken); 42await File.WriteAllTextAsync(settingsFilePath, jsonContent, cancellationToken); 49if (!File.Exists(settingsFilePath)) 56var existingContent = await File.ReadAllTextAsync(settingsFilePath, cancellationToken); 71await File.WriteAllTextAsync(settingsFilePath, jsonContent, cancellationToken); 103if (File.Exists(settingsFilePath)) 130var content = await File.ReadAllTextAsync(filePath, cancellationToken);
DotNet\DotNetCliRunner.cs (2)
902if (!File.Exists(filePath)) 910using var stream = File.OpenRead(filePath);
DotNet\DotNetSdkInstaller.cs (5)
44if (File.Exists(dotnetExecutable)) 158using var fileStream = File.Create(scriptPath); 169var mode = File.GetUnixFileMode(scriptPath); 171File.SetUnixFileMode(scriptPath, mode); 238File.Delete(scriptPath);
Packaging\NuGetConfigMerger.cs (1)
92File.Copy(tmpConfig.ConfigFile.FullName, targetPath, overwrite: true);
Projects\FallbackProjectParser.cs (1)
99var fileContent = File.ReadAllText(projectFile.FullName);
Projects\ProjectUpdater.cs (3)
514var fileContent = await File.ReadAllTextAsync(projectFile.FullName); 529await File.WriteAllTextAsync(projectFile.FullName, updatedContent); 638if (File.Exists(directoryPackagesPropsPath))
src\Shared\PathLookupHelper.cs (1)
23return FindFullPathFromPath(command, Environment.GetEnvironmentVariable("PATH"), Path.PathSeparator, File.Exists, pathExtensions);
Utils\CliDownloader.cs (2)
122if (File.Exists(lddPath)) 186var expectedChecksum = (await File.ReadAllTextAsync(checksumPath, cancellationToken)).Trim().ToLowerInvariant();
Utils\ConfigurationHelper.cs (2)
21if (File.Exists(settingsFilePath)) 31if (File.Exists(globalSettingsFile.FullName))
Aspire.Cli.Tests (246)
Agents\CommonAgentApplicatorsTests.cs (3)
52File.WriteAllText(agentsFilePath, "# Existing Content\n\nThis already exists."); 76Assert.True(File.Exists(agentsFilePath)); 77var content = await File.ReadAllTextAsync(agentsFilePath);
Agents\CopilotCliAgentEnvironmentScannerTests.cs (7)
54Assert.True(File.Exists(mcpConfigPath)); 56var content = await File.ReadAllTextAsync(mcpConfigPath); 107await File.WriteAllTextAsync(mcpConfigPath, existingConfig.ToJsonString()); 117var content = await File.ReadAllTextAsync(mcpConfigPath); 151await File.WriteAllTextAsync(mcpConfigPath, existingConfig.ToJsonString()); 154await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "AGENTS.md"), "# Agent Instructions"); 155await File.WriteAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "AGENTS.aspire.md"), "# Agent Instructions");
Agents\VsCodeAgentEnvironmentScannerTests.cs (8)
123Assert.True(File.Exists(mcpJsonPath)); 140Assert.True(File.Exists(mcpJsonPath)); 142var content = await File.ReadAllTextAsync(mcpJsonPath); 185await File.WriteAllTextAsync(mcpJsonPath, existingConfig.ToJsonString()); 195var content = await File.ReadAllTextAsync(mcpJsonPath); 226await File.WriteAllTextAsync(mcpJsonPath, existingConfig.ToJsonString()); 241var content = await File.ReadAllTextAsync(mcpJsonPath); 273var content = await File.ReadAllTextAsync(mcpJsonPath);
Caching\DiskCacheTests.cs (2)
127File.Move(current, oldName, overwrite: true); 132Assert.False(File.Exists(oldName));
Commands\ConfigCommandTests.cs (8)
71Assert.True(File.Exists(settingsPath)); 73var json = await File.ReadAllTextAsync(settingsPath); 94Assert.True(File.Exists(settingsPath)); 96var json = await File.ReadAllTextAsync(settingsPath); 119Assert.True(File.Exists(settingsPath)); 121var json = await File.ReadAllTextAsync(settingsPath); 153var json = await File.ReadAllTextAsync(settingsPath); 273var json = await File.ReadAllTextAsync(settingsPath);
Commands\InitCommandTests.cs (4)
67File.WriteAllText(solutionFile.FullName, "Fake solution file"); 122File.WriteAllText(solutionFile.FullName, "Fake solution file"); 251File.WriteAllText(appHostFile, "// Test apphost file"); 406File.WriteAllText(appHostFile, "// Test apphost file");
Commands\RunCommandTests.cs (8)
424File.WriteAllText(appHostProjectFile.FullName, "<Project></Project>"); 812await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 866await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 916await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 970await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 1019await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 1069await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 1119await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>");
Commands\UpdateCommandTests.cs (13)
89File.WriteAllText(oldBackup1, "test"); 90File.WriteAllText(oldBackup2, "test"); 91File.WriteAllText(otherFile, "test"); 99Assert.False(File.Exists(oldBackup1), "Old backup file should be deleted"); 100Assert.False(File.Exists(oldBackup2), "Old backup file should be deleted"); 101Assert.True(File.Exists(otherFile), "Other files should not be deleted"); 113File.WriteAllText(oldBackup, "test"); 125Assert.True(File.Exists(oldBackup), "Locked file should still exist on Windows"); 129Assert.False(File.Exists(oldBackup), "Locked file should be deleted on Mac/Linux"); 380File.WriteAllText(archivePath, "fake archive"); 427File.WriteAllText(archivePath, "fake archive"); 468File.WriteAllText(archivePath, "fake archive"); 921File.WriteAllText(archivePath, "fake archive");
DotNet\DotNetCliRunnerTests.cs (26)
35await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 84await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 122await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 170await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 217await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 267await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 363await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 411await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 461await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 516await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 571await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 632await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 701await File.WriteAllTextAsync(projectFile.FullName, "<Project></Project>"); 774await File.WriteAllTextAsync(solutionFile.FullName, "Not a real solution file."); 779await File.WriteAllTextAsync(project1File.FullName, "Not a real project file."); 783await File.WriteAllTextAsync(project2File.FullName, "Not a real project file."); 830await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 833await File.WriteAllTextAsync(referencedProject.FullName, "Not a real project file."); 872await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 927await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 981await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1035await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1095await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1153await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 1210await File.WriteAllTextAsync(appHostFile.FullName, "// Single-file AppHost"); 1255await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file.");
Packaging\NuGetConfigMergerSnapshotTests.cs (1)
47await File.WriteAllTextAsync(path, content);
Packaging\NuGetConfigMergerTests.cs (11)
24await File.WriteAllTextAsync(path, content); 66Assert.True(File.Exists(targetConfigPath)); 69var expected = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 70var actual = await File.ReadAllTextAsync(targetConfigPath); 90Assert.True(File.Exists(targetConfigPath)); 581Assert.True(File.Exists(targetConfigPath)); 611Assert.False(File.Exists(targetConfigPath)); 661Assert.True(File.Exists(targetConfigPath)); 682var originalContent = await File.ReadAllTextAsync(Path.Combine(root.FullName, "NuGet.config")); 704var currentContent = await File.ReadAllTextAsync(targetConfigPath); 726Assert.True(File.Exists(targetConfigPath));
Packaging\PackagingServiceTests.cs (2)
370Assert.True(File.Exists(nugetConfigPath)); 372var configContent = await File.ReadAllTextAsync(nugetConfigPath);
Packaging\TemporaryNuGetConfigTests.cs (3)
26var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 65var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName); 96var configContent = await File.ReadAllTextAsync(tempConfig.ConfigFile.FullName);
Projects\FallbackProjectParserTests.cs (14)
32await File.WriteAllTextAsync(projectFile, projectContent); 57await File.WriteAllTextAsync(projectFile, projectContent); 82await File.WriteAllTextAsync(projectFile, projectContent); 107await File.WriteAllTextAsync(projectFile, projectContent); 133await File.WriteAllTextAsync(projectFile, projectContent); 159await File.WriteAllTextAsync(projectFile, projectContent); 196await File.WriteAllTextAsync(projectFile, invalidProjectContent); 218await File.WriteAllTextAsync(projectFile, projectContent); 248await File.WriteAllTextAsync(projectFile, projectContent); 271await File.WriteAllTextAsync(projectFile, projectContent); 295await File.WriteAllTextAsync(projectFile, projectContent); 318await File.WriteAllTextAsync(projectFile, projectContent); 340await File.WriteAllTextAsync(projectFile, projectContent); 358await File.WriteAllTextAsync(projectFile, projectContent);
Projects\ProjectLocatorTests.cs (42)
61await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 65await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 100await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 104await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 136await File.WriteAllTextAsync(realAppHostProjectFile.FullName, "Not a real apphost project"); 181await File.WriteAllTextAsync(targetAppHostProjectFile.FullName, "Not a real apphost"); 216await File.WriteAllTextAsync(projectFile1.FullName, "Not a real project file."); 219await File.WriteAllTextAsync(projectFile2.FullName, "Not a real project file."); 239await File.WriteAllTextAsync(appHostProject.FullName, "Not a real apphost project."); 242await File.WriteAllTextAsync(webProject.FullName, "Not a real web project."); 294await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 313await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 335await File.WriteAllTextAsync(appHostProjectFile.FullName, "Not a real project file."); 360var settingsJson = await File.ReadAllTextAsync(settingsFile.FullName); 376await File.WriteAllTextAsync( 404await File.WriteAllTextAsync( 434await File.WriteAllTextAsync( 444await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 449await File.WriteAllTextAsync( 485await File.WriteAllTextAsync(appHostFile.FullName, @"using Aspire.Hosting; 509await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 514await File.WriteAllTextAsync( 557await File.WriteAllTextAsync( 585await File.WriteAllTextAsync(appHostFile.FullName, @"using Aspire.Hosting; 609await File.WriteAllTextAsync( 620await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 639await File.WriteAllTextAsync(txtFile.FullName, "Some text file"); 663await File.WriteAllTextAsync(csprojFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 668await File.WriteAllTextAsync( 774await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 833await File.WriteAllTextAsync(projectFile1.FullName, "Not a real project file."); 835await File.WriteAllTextAsync(projectFile2.FullName, "Not a real project file."); 871await File.WriteAllTextAsync( 903await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file."); 937await File.WriteAllTextAsync(exeProjectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType></PropertyGroup></Project>"); 942await File.WriteAllTextAsync(libProjectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Library</OutputType></PropertyGroup></Project>"); 978await File.WriteAllTextAsync(winExeProjectFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>WinExe</OutputType></PropertyGroup></Project>"); 1013await File.WriteAllTextAsync(lib1File.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Library</OutputType></PropertyGroup></Project>"); 1017await File.WriteAllTextAsync(lib2File.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Library</OutputType></PropertyGroup></Project>"); 1069await File.WriteAllTextAsync(exe1File.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType></PropertyGroup></Project>"); 1073await File.WriteAllTextAsync(exe2File.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType></PropertyGroup></Project>"); 1077await File.WriteAllTextAsync(winExeFile.FullName, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>WinExe</OutputType></PropertyGroup></Project>");
Projects\ProjectUpdaterTests.cs (54)
37await File.WriteAllTextAsync( 147await File.WriteAllTextAsync( 278await File.WriteAllTextAsync( 431await File.WriteAllTextAsync( 561await File.WriteAllTextAsync( 570await File.WriteAllTextAsync( 584await File.WriteAllTextAsync( 676var updatedContent = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 694await File.WriteAllTextAsync( 706await File.WriteAllTextAsync( 781var updatedContent = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 796await File.WriteAllTextAsync( 808await File.WriteAllTextAsync( 884var content = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 929await File.WriteAllTextAsync( 941await File.WriteAllTextAsync( 1027var content = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 1042await File.WriteAllTextAsync( 1055await File.WriteAllTextAsync( 1150var content = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 1166await File.WriteAllTextAsync( 1178await File.WriteAllTextAsync( 1280await File.WriteAllTextAsync( 1292await File.WriteAllTextAsync( 1389await File.WriteAllTextAsync( 1485await File.WriteAllTextAsync( 1497await File.WriteAllTextAsync( 1585await File.WriteAllTextAsync( 1663await File.WriteAllTextAsync( 1746await File.WriteAllTextAsync( 1815var updatedContent = await File.ReadAllTextAsync(appHostFile.FullName); 1829await File.WriteAllTextAsync( 1898var updatedContent = await File.ReadAllTextAsync(appHostFile.FullName); 1910await File.WriteAllTextAsync( 1997await File.WriteAllTextAsync( 2061var updatedContent = await File.ReadAllTextAsync(appHostProjectFile.FullName); 2075await File.WriteAllTextAsync( 2140var updatedContent = await File.ReadAllTextAsync(appHostProjectFile.FullName); 2152await File.WriteAllTextAsync( 2262await File.WriteAllTextAsync( 2279await File.WriteAllTextAsync( 2372var directoryPackagesContent = await File.ReadAllTextAsync(directoryPackagesPropsFile.FullName); 2392await File.WriteAllTextAsync(projectFile, originalContent); 2400var updatedContent = await File.ReadAllTextAsync(projectFile); 2419await File.WriteAllTextAsync(projectFile, originalContent); 2427var updatedContent = await File.ReadAllTextAsync(projectFile); 2451await File.WriteAllTextAsync(projectFile, originalContent); 2459var updatedContent = await File.ReadAllTextAsync(projectFile); 2482await File.WriteAllTextAsync(projectFile, originalContent); 2490var updatedContent = await File.ReadAllTextAsync(projectFile); 2509await File.WriteAllTextAsync(projectFile, originalContent); 2517var updatedContent = await File.ReadAllTextAsync(projectFile); 2537await File.WriteAllTextAsync(projectFile, originalContent); 2545var updatedContent = await File.ReadAllTextAsync(projectFile);
Templating\DotNetTemplateFactoryTests.cs (16)
55await File.WriteAllTextAsync(path, content); 80Assert.True(File.Exists(nugetConfigPath), "NuGet.config should be created in working directory for in-place creation"); 112Assert.True(File.Exists(nugetConfigPath), "NuGet.config should exist in working directory"); 114var content = await File.ReadAllTextAsync(nugetConfigPath); 150var parentContent = await File.ReadAllTextAsync(parentConfigPath); 156Assert.True(File.Exists(outputConfigPath), "NuGet.config should be created in output directory"); 158var outputContent = await File.ReadAllTextAsync(outputConfigPath); 192Assert.True(File.Exists(outputConfigPath), "NuGet.config should exist in output directory"); 194var content = await File.ReadAllTextAsync(outputConfigPath); 219Assert.False(File.Exists(workingConfigPath), "No NuGet.config should be created in working directory"); 223Assert.True(File.Exists(outputConfigPath), "NuGet.config should be created in output directory"); 225var content = await File.ReadAllTextAsync(outputConfigPath); 246Assert.False(File.Exists(workingConfigPath), "No NuGet.config should be created for implicit channel"); 247Assert.False(File.Exists(outputConfigPath), "No NuGet.config should be created for implicit channel"); 267Assert.False(File.Exists(workingConfigPath), "No NuGet.config should be created when no mappings exist"); 268Assert.False(File.Exists(outputConfigPath), "No NuGet.config should be created when no mappings exist");
Utils\FileSystemHelperTests.cs (24)
19File.WriteAllText(Path.Combine(sourceDir.FullName, "file1.txt"), "content1"); 20File.WriteAllText(Path.Combine(sourceDir.FullName, "file2.txt"), "content2"); 21File.WriteAllText(Path.Combine(sourceDir.FullName, "file3.cs"), "using System;"); 28Assert.True(File.Exists(Path.Combine(destDir, "file1.txt"))); 29Assert.True(File.Exists(Path.Combine(destDir, "file2.txt"))); 30Assert.True(File.Exists(Path.Combine(destDir, "file3.cs"))); 32Assert.Equal("content1", File.ReadAllText(Path.Combine(destDir, "file1.txt"))); 33Assert.Equal("content2", File.ReadAllText(Path.Combine(destDir, "file2.txt"))); 34Assert.Equal("using System;", File.ReadAllText(Path.Combine(destDir, "file3.cs"))); 49File.WriteAllText(Path.Combine(sourceDir.FullName, "root.txt"), "root content"); 50File.WriteAllText(Path.Combine(subDir1.FullName, "level1.txt"), "level 1 content"); 51File.WriteAllText(Path.Combine(subDir2.FullName, "level2.txt"), "level 2 content"); 58Assert.True(File.Exists(Path.Combine(destDir, "root.txt"))); 60Assert.True(File.Exists(Path.Combine(destDir, "subdir1", "level1.txt"))); 62Assert.True(File.Exists(Path.Combine(destDir, "subdir1", "subdir2", "level2.txt"))); 64Assert.Equal("root content", File.ReadAllText(Path.Combine(destDir, "root.txt"))); 65Assert.Equal("level 1 content", File.ReadAllText(Path.Combine(destDir, "subdir1", "level1.txt"))); 66Assert.Equal("level 2 content", File.ReadAllText(Path.Combine(destDir, "subdir1", "subdir2", "level2.txt"))); 159File.WriteAllBytes(binaryFilePath, randomBytes); 166Assert.True(File.Exists(copiedFilePath)); 168var copiedBytes = File.ReadAllBytes(copiedFilePath); 185File.WriteAllText(Path.Combine(current.FullName, $"file{i}.txt"), $"content at level {i}"); 198Assert.True(File.Exists(filePath)); 199Assert.Equal($"content at level {i}", File.ReadAllText(filePath));
Aspire.Dashboard.Tests (11)
Integration\OtlpGrpcServiceTests.cs (2)
176await File.WriteAllTextAsync(configPath, configJson.ToString()).DefaultTimeout(); 219await File.WriteAllTextAsync(configPath, configJson.ToString()).DefaultTimeout();
Integration\StartupTests.cs (6)
185File.Delete(browserTokenConfigFile); 217await File.WriteAllTextAsync(browserTokenConfigFile, changedFrontendBrowserToken).DefaultTimeout(); 232File.Delete(browserTokenConfigFile); 646await File.WriteAllTextAsync(configFilePath, configJson.ToString()).DefaultTimeout(); 669File.Delete(configFilePath); 1013await File.WriteAllTextAsync(browserTokenConfigFile, browserToken);
tests\Shared\Playwright\PlaywrightProvider.cs (2)
20if (!string.IsNullOrEmpty(browserPath) && !File.Exists(browserPath)) 31if (File.Exists(probePath))
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
Aspire.EndToEnd.Tests (18)
tests\Shared\Playwright\PlaywrightProvider.cs (2)
20if (!string.IsNullOrEmpty(browserPath) && !File.Exists(browserPath)) 31if (File.Exists(probePath))
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
tests\Shared\TemplatesTesting\AspireProject.cs (9)
65File.WriteAllText(Path.Combine(dir, "Directory.Build.props"), "<Project />"); 66File.WriteAllText(Path.Combine(dir, "Directory.Build.targets"), "<Project />"); 73File.Copy(srcNuGetConfigPath, targetNuGetConfigPath); 107File.WriteAllText(Path.Combine(rootDir, "Directory.Build.props"), "<Project />"); 108File.WriteAllText(Path.Combine(rootDir, "Directory.Build.targets"), "<Project />"); 131var csprojContent = File.ReadAllText(csprojPath); 151File.Copy(Path.Combine(BuildEnvironment.TestAssetsPath, "EndPointWriterHook_cs"), Path.Combine(project.AppHostProjectDirectory, "EndPointWriterHook.cs")); 153string programCs = File.ReadAllText(programCsPath); 156File.WriteAllText(programCsPath, programCs);
tests\Shared\TemplatesTesting\BuildEnvironment.cs (2)
101.FirstOrDefault(File.Exists); 124.FirstOrDefault(File.Exists);
tests\Shared\TemplatesTesting\TemplateCustomHive.cs (4)
18public string CustomHiveDirectory => File.Exists(_stampFilePath) 37if (BuildEnvironment.IsRunningOnCI && File.Exists(_stampFilePath)) 51if (File.Exists(_stampFilePath)) 80File.WriteAllText(_stampFilePath, "");
Aspire.Hosting (61)
ApplicationModel\AspireStore.cs (4)
58using (var fileStream = File.OpenWrite(tempFileName)) 68if (!File.Exists(finalFilePath)) 70File.Copy(tempFileName, finalFilePath, overwrite: true); 75File.Delete(tempFileName);
ApplicationModel\AspireStoreExtensions.cs (2)
25if (!File.Exists(sourceFilename)) 30using var sourceStream = File.OpenRead(sourceFilename);
ApplicationModel\ContainerFileSystemCallbackAnnotation.cs (1)
201if (File.Exists(fullPath))
ApplicationModel\DockerfileBuildAnnotation.cs (1)
99await File.WriteAllTextAsync(DockerfilePath, dockerfileContent, cancellationToken).ConfigureAwait(false);
ApplicationModel\ProjectResource.cs (2)
210if (File.Exists(tempDockerfilePath)) 214File.Delete(tempDockerfilePath);
Backchannel\AuxiliaryBackchannelService.cs (4)
50if (File.Exists(SocketPath)) 52File.Delete(SocketPath); 96if (SocketPath != null && File.Exists(SocketPath)) 100File.Delete(SocketPath);
ContainerResourceBuilderExtensions.cs (1)
1295if (!Directory.Exists(sourceFullPath) && !File.Exists(sourceFullPath))
Dashboard\DashboardEventHandlers.cs (9)
141if (!File.Exists(runtimeConfigPath)) 148var configText = File.ReadAllText(runtimeConfigPath); 213if (!File.Exists(originalRuntimeConfig)) 233File.WriteAllText(customConfigPath, JsonSerializer.Serialize(defaultConfig, new JsonSerializerOptions { WriteIndented = true })); 240var originalConfigText = File.ReadAllText(originalRuntimeConfig); 275File.WriteAllText(tempPath, configJson.ToJsonString(new JsonSerializerOptions { WriteIndented = true })); 318if (!File.Exists(dashboardDll)) 332if (!File.Exists(dashboardDll)) 879File.Delete(_customRuntimeConfigPath);
Dcp\DcpDependencyCheck.cs (1)
47if (!File.Exists(dcpPath))
Dcp\DcpExecutor.cs (9)
1669File.WriteAllText(Path.Join(baseServerAuthOutputPath, $"{thumbprint}.crt"), publicCetificatePem); 1676File.WriteAllBytes(Path.Join(baseServerAuthOutputPath, $"{thumbprint}.key"), keyBytes); 1684File.WriteAllBytes(Path.Join(baseServerAuthOutputPath, $"{thumbprint}.pfx"), pfxBytes); 2599if (File.Exists(keyFileName)) 2601var keyCandidate = File.ReadAllText(keyFileName); 2652await File.WriteAllTextAsync(keyFileName, new string(pemKey), cancellationToken).ConfigureAwait(false); 2672if (File.Exists(pfxFileName)) 2674var pfxCandidate = File.ReadAllBytes(pfxFileName); 2703File.WriteAllBytes(pfxFileName, pfxBytes);
Dcp\DcpHost.cs (1)
176if (!File.Exists(dcpExePath))
Devcontainers\DevcontainerSettingsWriter.cs (4)
119var settingsContent = await File.ReadAllTextAsync(settingsPath, cancellationToken).ConfigureAwait(false); 185await File.WriteAllTextAsync(settingsPath, settingsContent, cancellationToken).ConfigureAwait(false); 247if (!File.Exists(path)) 255using var stream = File.Open(path, FileMode.CreateNew);
DistributedApplicationBuilder.cs (1)
824if (!File.Exists(deploymentStatePath))
DistributedApplicationOptions.cs (3)
180if (File.Exists(csprojPath)) 187else if (File.Exists(fullPath) && fullPath.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase)) 201if (File.Exists(csprojPath))
Pipelines\DistributedApplicationPipeline.cs (2)
74if (deploymentStateManager.StateFilePath is string stateFilePath && File.Exists(stateFilePath)) 110File.Delete(stateFilePath);
Pipelines\Internal\DeploymentStateManagerBase.cs (2)
87if (statePath is not null && File.Exists(statePath)) 89var fileContent = await File.ReadAllTextAsync(statePath, cancellationToken).ConfigureAwait(false);
Pipelines\Internal\FileDeploymentStateManager.cs (1)
68await File.WriteAllTextAsync(
Publishing\ManifestPublishingContext.cs (1)
381File.Copy(annotation.DockerfilePath, resourceDockerfilePath, overwrite: true);
src\Shared\LaunchProfiles\LaunchProfileExtensions.cs (4)
77if (!File.Exists(projectMetadata.ProjectPath)) 91if (!File.Exists(launchSettingsFilePath)) 101if (File.Exists(runSettingsFilePath)) 112using var stream = File.OpenRead(launchSettingsFilePath);
UserSecrets\UserSecretsManagerFactory.cs (4)
147await File.WriteAllTextAsync(FilePath, json, Encoding.UTF8, cancellationToken).ConfigureAwait(false); 189File.WriteAllText(tempFilename, json, Encoding.UTF8); 190File.Move(tempFilename, FilePath, overwrite: true); 194File.WriteAllText(FilePath, json, Encoding.UTF8);
Utils\DockerfileHelper.cs (1)
45var dockerfileContent = await File.ReadAllTextAsync(annotation.DockerfilePath, cancellationToken).ConfigureAwait(false);
Utils\FileSystemService.cs (3)
162File.Create(filePath).Dispose(); 262if (File.Exists(_path)) 264File.Delete(_path);
Aspire.Hosting.Azure (12)
AzureBicepResource.cs (4)
169File.WriteAllText(path, TemplateString); 181using var fs = File.OpenWrite(path); 214return File.ReadAllText(TemplateFile); 564File.Delete(Path);
AzureProvisioningResource.cs (3)
94File.WriteAllText(moduleSourcePath, compiledBicep.Value); 97File.Copy(moduleSourcePath, moduleDestinationPath, true); 110_generatedBicep = File.ReadAllText(template.Path);
AzurePublishingContext.cs (4)
160File.Copy(file.Path, modulePath, true); 329File.Copy(dockerfileBuildAnnotation.DockerfilePath, resourceDockerfilePath, overwrite: true); 344File.Copy(file.Path, modulePath, true); 476await File.WriteAllTextAsync(bicepPath, compiledBicep.Value).ConfigureAwait(false);
src\Shared\PathLookupHelper.cs (1)
23return FindFullPathFromPath(command, Environment.GetEnvironmentVariable("PATH"), Path.PathSeparator, File.Exists, pathExtensions);
Aspire.Hosting.Azure.Functions (6)
src\Shared\LaunchProfiles\LaunchProfileExtensions.cs (4)
77if (!File.Exists(projectMetadata.ProjectPath)) 91if (!File.Exists(launchSettingsFilePath)) 101if (File.Exists(runSettingsFilePath)) 112using var stream = File.OpenRead(launchSettingsFilePath);
src\Shared\PathLookupHelper.cs (1)
23return FindFullPathFromPath(command, Environment.GetEnvironmentVariable("PATH"), Path.PathSeparator, File.Exists, pathExtensions);
src\Shared\RequiredCommandValidator.cs (1)
184return File.Exists(candidate) ? candidate : null;
Aspire.Hosting.Azure.Tests (61)
AzureAppServiceTests.cs (1)
193File.WriteAllText(Path.Combine(directory.FullName, "Dockerfile"), "");
AzureContainerAppsTests.cs (2)
66File.WriteAllText(Path.Combine(directory.FullName, "Dockerfile"), ""); 2011File.WriteAllText(Path.Combine(tempDirectory.Path, "Dockerfile"), "FROM alpine");
AzureDeployerTests.cs (26)
1298if (File.Exists(deploymentStatePath)) 1300File.Delete(deploymentStatePath); 1306Assert.True(File.Exists(deploymentStatePath)); 1307var stateContent = await File.ReadAllTextAsync(deploymentStatePath); 1312if (File.Exists(deploymentStatePath)) 1314File.Delete(deploymentStatePath); 1336await File.WriteAllTextAsync(deploymentStatePath, cachedState.ToJsonString()); 1358Assert.True(File.Exists(deploymentStatePath)); 1360if (File.Exists(deploymentStatePath)) 1362File.Delete(deploymentStatePath); 1387if (File.Exists(deploymentStatePath)) 1389File.Delete(deploymentStatePath); 1395Assert.False(File.Exists(deploymentStatePath)); 1420if (File.Exists(stagingStatePath)) 1422File.Delete(stagingStatePath); 1428Assert.True(File.Exists(stagingStatePath)); 1429var stateContent = await File.ReadAllTextAsync(stagingStatePath); 1433if (File.Exists(stagingStatePath)) 1435File.Delete(stagingStatePath); 1481Assert.False(File.Exists(deploymentStatePath)); 1511Assert.True(File.Exists(deploymentStatePath)); 1512firstDeploymentState = await File.ReadAllTextAsync(deploymentStatePath); 1566Assert.True(File.Exists(deploymentStatePath)); 1567secondDeploymentState = await File.ReadAllTextAsync(deploymentStatePath); 1578if (deploymentStatePath is not null && File.Exists(deploymentStatePath)) 1580File.Delete(deploymentStatePath);
AzureEnvironmentResourceTests.cs (16)
34Assert.True(File.Exists(mainBicepPath)); 35var mainBicep = File.ReadAllText(mainBicepPath); 38Assert.True(File.Exists(envBicepPath)); 39var envBicep = File.ReadAllText(envBicepPath); 71Assert.True(File.Exists(mainBicepPath)); 72var mainBicep = File.ReadAllText(mainBicepPath); 122Assert.True(File.Exists(mainBicepPath)); 123var content = File.ReadAllText(mainBicepPath); 169var mainBicep = File.ReadAllText(Path.Combine(tempDir.FullName, "main.bicep")); 170var storageBicep = File.ReadAllText(Path.Combine(tempDir.FullName, "storage", "storage.bicep")); 204Assert.True(File.Exists(mainBicepPath)); 205var mainBicep = File.ReadAllText(mainBicepPath); 209Assert.True(File.Exists(includedStorageBicepPath), "Included storage should have a bicep file generated"); 213Assert.False(File.Exists(excludedStorageBicepPath), "Excluded storage should not have a bicep file generated"); 235Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 236var actualContent = await File.ReadAllTextAsync(dockerfilePath);
AzureEventHubsExtensionsTests.cs (2)
476File.WriteAllText(configJsonPath, source); 497File.Delete(configJsonPath);
AzureFunctionsTests.cs (7)
617File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 642File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 664File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 696File.WriteAllText(projectPath1, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 697File.WriteAllText(projectPath2, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 718File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>"); 750File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>");
AzureManifestUtils.cs (2)
38if (pathNode?.ToString() is not { } path || !File.Exists(Path.Combine(manifestDir, path))) 43var bicepText = await File.ReadAllTextAsync(Path.Combine(manifestDir, path));
AzureResourceOptionsTests.cs (2)
44var sbBicep = await File.ReadAllTextAsync(Path.Combine(tempDir.FullName, "sb.module.bicep")); 46var sqlBicep = await File.ReadAllTextAsync(Path.Combine(tempDir.FullName, "sql-server.module.bicep"));
AzureServiceBusExtensionsTests.cs (3)
558File.WriteAllText(configJsonPath, """ 594File.Delete(configJsonPath); 783File.WriteAllText(configJsonPath,
Aspire.Hosting.Containers.Tests (6)
DockerSocketBindMountTests.cs (3)
25await File.WriteAllTextAsync(dockerFilePath, dockerfile); 49Assert.True(File.Exists(infoFile)); 51var infoContent = await File.ReadAllTextAsync(infoFile);
WithDockerfileTests.cs (3)
906Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 907var actualContent = await File.ReadAllTextAsync(dockerfilePath); 910var manifestContent = await File.ReadAllTextAsync(manifestPath);
Aspire.Hosting.DevTunnels (2)
src\Shared\PathLookupHelper.cs (1)
23return FindFullPathFromPath(command, Environment.GetEnvironmentVariable("PATH"), Path.PathSeparator, File.Exists, pathExtensions);
src\Shared\RequiredCommandValidator.cs (1)
184return File.Exists(candidate) ? candidate : null;
Aspire.Hosting.Docker (11)
DockerComposeEnvironmentResource.cs (3)
217if (!File.Exists(dockerComposeFilePath)) 279if (!File.Exists(dockerComposeFilePath)) 393if (File.Exists(envFilePath))
DockerComposePublishingContext.cs (3)
100File.Copy(dockerfileBuildAnnotation.DockerfilePath, resourceDockerfilePath, overwrite: true); 151await File.WriteAllTextAsync(outputFile, composeOutput, cancellationToken).ConfigureAwait(false); 200File.Copy(file.SourcePath, sourcePath);
EnvFile.cs (5)
30if (!File.Exists(path)) 37foreach (var line in File.ReadAllLines(path)) 95if (File.Exists(_path)) 112File.WriteAllLines(_path, lines); 157File.WriteAllLines(_path, lines);
Aspire.Hosting.Docker.Tests (88)
DockerComposePublisherTests.cs (68)
99Assert.True(File.Exists(composePath)); 100Assert.True(File.Exists(envPath)); 102await Verify(File.ReadAllText(composePath), "yaml") 103.AppendContentAsFile(File.ReadAllText(envPath), "env"); 136Assert.True(File.Exists(composePath)); 137Assert.True(File.Exists(envPath)); 139await Verify(File.ReadAllText(composePath), "yaml") 140.AppendContentAsFile(File.ReadAllText(envPath), "env"); 163Assert.True(File.Exists(composePath)); 165await Verify(File.ReadAllText(composePath), "yaml"); 192Assert.True(File.Exists(composePath)); 241Assert.True(File.Exists(composePath)); 243Assert.True(File.Exists(envPath)); 245await Verify(File.ReadAllText(composePath), "yaml") 246.AppendContentAsFile(File.ReadAllText(envPath), "env"); 268Assert.True(File.Exists(envFilePath)); 269var firstContent = File.ReadAllText(envFilePath).Replace("PARAM1=", "PARAM1=changed"); 270File.WriteAllText(envFilePath, firstContent); 273Assert.True(File.Exists(envFilePath)); 274var secondContent = File.ReadAllText(envFilePath); 309Assert.True(File.Exists(envFilePath)); 310var firstContent = File.ReadAllText(envFilePath).Replace("PARAM1=", "PARAM1=changed"); 311File.WriteAllText(envFilePath, firstContent); 314Assert.True(File.Exists(envFilePath)); 315var secondContent = File.ReadAllText(envFilePath); 340Assert.True(File.Exists(composePath)); 342var composeFile = File.ReadAllText(composePath); 366Assert.True(File.Exists(composePath)); 368var composeContent = File.ReadAllText(composePath); 392Assert.True(File.Exists(composePath)); 394var composeContent = File.ReadAllText(composePath); 420Assert.True(File.Exists(composePath)); 422var composeContent = File.ReadAllText(composePath); 452Assert.True(File.Exists(composePath)); 454var composeContent = File.ReadAllText(composePath); 477Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 478var actualContent = await File.ReadAllTextAsync(dockerfilePath); 501Assert.False(File.Exists(composePath)); 527var envFileContent = await File.ReadAllTextAsync(Path.Combine(tempDir.Path, ".env.Production")); 557Assert.True(File.Exists(envFilePath), $"Expected env file at {envFilePath}"); 559var envFileContent = await File.ReadAllTextAsync(envFilePath); 590var envFileContent = await File.ReadAllTextAsync(Path.Combine(tempDir.Path, ".env.Production")); 613File.WriteAllText(envFilePath, "# Old content\nOLD_KEY=old_value\n"); 619var envFileContent = File.ReadAllText(envFilePath); 647File.WriteAllText(envFilePath, "# Old staging content\nOLD_STAGING_KEY=old_staging_value\n"); 653var envFileContent = File.ReadAllText(envFilePath); 679Assert.True(File.Exists(composePath)); 680Assert.True(File.Exists(envPath)); 682await Verify(File.ReadAllText(composePath), "yaml") 683.AppendContentAsFile(File.ReadAllText(envPath), "env"); 705Assert.True(File.Exists(composePath)); 707var composeContent = File.ReadAllText(composePath); 737Assert.True(File.Exists(composePath)); 738Assert.True(File.Exists(envPath)); 740await Verify(File.ReadAllText(composePath), "yaml") 741.AppendContentAsFile(File.ReadAllText(envPath), "env"); 776Assert.True(File.Exists(composePath)); 777Assert.True(File.Exists(envPath)); 779await Verify(File.ReadAllText(composePath), "yaml") 780.AppendContentAsFile(File.ReadAllText(envPath), "env"); 824Assert.True(File.Exists(composePath)); 825Assert.True(File.Exists(envPath)); 827await Verify(File.ReadAllText(composePath), "yaml") 828.AppendContentAsFile(File.ReadAllText(envPath), "env"); 858Assert.True(File.Exists(composePath)); 859Assert.True(File.Exists(envPath)); 861await Verify(File.ReadAllText(composePath), "yaml") 862.AppendContentAsFile(File.ReadAllText(envPath), "env");
DockerComposeTests.cs (8)
60Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 85Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 87var composeContent = File.ReadAllText(composeFile); 168Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 169var composeContent = File.ReadAllText(composeFile); 202Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 203var composeContent = File.ReadAllText(composeFile); 291Assert.True(File.Exists(composePath));
EnvFileTests.cs (12)
15File.WriteAllLines(envFilePath, [ 26var lines = File.ReadAllLines(envFilePath); 41File.WriteAllLines(envFilePath, [ 52var lines = File.ReadAllLines(envFilePath); 67File.WriteAllLines(envFilePath, [ 87var lines = File.ReadAllLines(envFilePath); 107File.WriteAllLines(envFilePath, [ 118var lines = File.ReadAllLines(envFilePath); 132File.WriteAllText(envFilePath, string.Empty); 138var lines = File.ReadAllLines(envFilePath); 153Assert.True(File.Exists(envFilePath)); 154var lines = File.ReadAllLines(envFilePath);
Aspire.Hosting.Garnet.Tests (1)
GarnetFunctionalTests.cs (1)
141File.SetUnixFileMode(bindMountPath, BindMountPermissions);
Aspire.Hosting.JavaScript (17)
JavaScriptHostingExtensions.cs (17)
150if (File.Exists(Path.Combine(resource.WorkingDirectory, "Dockerfile"))) 254if (File.Exists(Path.Combine(appDirectory, "package.json"))) 383if (File.Exists(Path.Combine(appDirectory, "Dockerfile"))) 576if (File.Exists(candidatePath)) 598File.WriteAllText(aspireConfigPath, aspireConfig); 717File.Exists(Path.Combine(resource.Resource.WorkingDirectory, "package-lock.json")) 733var hasYarnLock = File.Exists(Path.Combine(workingDirectory, "yarn.lock")); 734var hasYarnrc = File.Exists(Path.Combine(workingDirectory, ".yarnrc.yml")); 800var hasPnpmLock = File.Exists(Path.Combine(workingDirectory, "pnpm-lock.yaml")); 948if (File.Exists(nvmrcPath)) 950var versionString = File.ReadAllText(nvmrcPath).Trim(); 960if (File.Exists(nodeVersionPath)) 962var versionString = File.ReadAllText(nodeVersionPath).Trim(); 972if (File.Exists(packageJsonPath)) 976using var stream = File.OpenRead(packageJsonPath); 997if (File.Exists(toolVersionsPath)) 999var lines = File.ReadAllLines(toolVersionsPath);
Aspire.Hosting.JavaScript.Tests (50)
AddJavaScriptAppTests.cs (7)
30var dockerfileContents = File.ReadAllText(dockerfilePath); 63File.WriteAllText(Path.Combine(appDir, "pnpm-lock.yaml"), string.Empty); 73var dockerfileContents = File.ReadAllText(dockerfilePath); 100await File.WriteAllTextAsync(Path.Combine(appDir, "package.json"), packageJson); 109Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 112var dockerfileContent = await File.ReadAllTextAsync(dockerfilePath); 121await File.WriteAllTextAsync(dockerfileInContext, modifiedDockerfile);
AddNodeAppTests.cs (17)
97File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 98File.WriteAllText(Path.Combine(appDir, "package-lock.json"), "{}"); 106var dockerfileContents = File.ReadAllText(dockerfilePath); 162File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 175var dockerfileContents = File.ReadAllText(dockerfilePath); 209File.WriteAllText(Path.Combine(appDir, "package.json"), "{}"); 220var dockerfileContents = File.ReadAllText(Path.Combine(tempDir.Path, "js.Dockerfile")); 229File.WriteAllText(Path.Combine(tempDir.Path, "app.js"), "{}"); 256File.WriteAllText(Path.Combine(tempDir.Path, "package.json"), "{}"); 329File.WriteAllText(Path.Combine(appDirectory, "package.json"), packageJsonContent); 330File.WriteAllText(Path.Combine(appDirectory, "app.js"), appContent); 356Assert.True(File.Exists(nodeDockerfilePath), "Dockerfile should be generated for NodeApp"); 358var dockerfileContent = File.ReadAllText(nodeDockerfilePath); 385File.WriteAllText(Path.Combine(appDirectory, "package.json"), packageJsonContent); 386File.WriteAllText(Path.Combine(appDirectory, "app.js"), appContent); 412Assert.True(File.Exists(nodeDockerfilePath), "Dockerfile should be generated for NodeApp"); 414var dockerfileContent = File.ReadAllText(nodeDockerfilePath);
AddViteAppTests.cs (18)
26File.WriteAllText(Path.Combine(viteDir, "package-lock.json"), "empty"); 58var dockerfileContents = File.ReadAllText(dockerfilePath); 91File.WriteAllText(Path.Combine(tempDir.Path, "package.json"), packageJson); 99var dockerfileContents = File.ReadAllText(Path.Combine(tempDir.Path, "vite.Dockerfile")); 111File.WriteAllText(Path.Combine(tempDir.Path, ".nvmrc"), "18.20.0"); 119var dockerfileContents = File.ReadAllText(Path.Combine(tempDir.Path, "vite.Dockerfile")); 131File.WriteAllText(Path.Combine(tempDir.Path, ".node-version"), "v21.5.0"); 139var dockerfileContents = File.ReadAllText(Path.Combine(tempDir.Path, "vite.Dockerfile")); 156File.WriteAllText(Path.Combine(tempDir.Path, ".tool-versions"), toolVersions); 164var dockerfileContents = File.ReadAllText(Path.Combine(tempDir.Path, "vite.Dockerfile")); 182var dockerfileContents = File.ReadAllText(Path.Combine(tempDir.Path, "vite.Dockerfile")); 198File.WriteAllText(Path.Combine(tempDir.Path, ".nvmrc"), versionString); 206var dockerfileContents = File.ReadAllText(Path.Combine(tempDir.Path, "vite.Dockerfile")); 228var dockerfileContents = File.ReadAllText(Path.Combine(tempDir.Path, "vite.Dockerfile")); 291File.WriteAllText(viteConfigPath, "export default {}"); 352File.WriteAllText(viteConfigPath, "export default {}"); 456File.WriteAllText(viteConfigPath, "export default {}"); 517File.WriteAllText(viteConfigPath, "export default {}");
NodeAppFixture.cs (2)
75File.WriteAllText(Path.Combine(tempDir, "app.js"), 95File.WriteAllText(Path.Combine(tempDir, "package.json"),
PackageInstallationTests.cs (6)
458File.WriteAllText(Path.Combine(tempDir.Path, "package-lock.json"), "empty"); 485File.WriteAllText(Path.Combine(tempDir.Path, "yarn.lock"), "empty"); 506File.WriteAllText(Path.Combine(tempDir.Path, "yarn.lock"), "empty"); 507File.WriteAllText(Path.Combine(tempDir.Path, ".yarnrc.yml"), "empty"); 522File.WriteAllText(Path.Combine(tempDir.Path, "yarn.lock"), "empty"); 538File.WriteAllText(Path.Combine(tempDir.Path, "pnpm-lock.yaml"), "empty");
Aspire.Hosting.Kafka.Tests (1)
KafkaFunctionalTests.cs (1)
155File.SetUnixFileMode(bindMountPath, BindMountPermissions);
Aspire.Hosting.Keycloak.Tests (1)
KeycloakPublicApiTests.cs (1)
182File.WriteAllText(filePath, string.Empty);
Aspire.Hosting.Kubernetes (3)
KubernetesPublishingContext.cs (3)
88File.Copy(dockerfileBuildAnnotation.DockerfilePath, resourceDockerfilePath, overwrite: true); 193await File.WriteAllTextAsync(outputFile, valuesYaml, cancellationToken).ConfigureAwait(false); 213await File.WriteAllTextAsync(outputFile, chartYaml, cancellationToken).ConfigureAwait(false);
Aspire.Hosting.Kubernetes.Tests (17)
KubernetesEnvironmentResourceTests.cs (3)
32await Verify(File.ReadAllText(chartYaml), "yaml") 33.AppendContentAsFile(File.ReadAllText(valuesYaml), "yaml") 34.AppendContentAsFile(File.ReadAllText(deploymentYaml), "yaml");
KubernetesPublisherTests.cs (14)
68settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 72settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 103Assert.True(File.Exists(deploymentPath)); 105var content = await File.ReadAllTextAsync(deploymentPath); 163settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 167settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 217settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 221settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 272settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 276settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension); 300Assert.True(File.Exists(dockerfilePath), $"Dockerfile should exist at {dockerfilePath}"); 301var actualContent = await File.ReadAllTextAsync(dockerfilePath); 399settingsTask = Verify(File.ReadAllText(filePath), fileExtension); 403settingsTask = settingsTask.AppendContentAsFile(File.ReadAllText(filePath), fileExtension);
Aspire.Hosting.Maui (2)
Utilities\MauiEnvironmentHelper.cs (2)
82await File.WriteAllTextAsync(targetsFilePath, targetsContent, Encoding.UTF8, cancellationToken).ConfigureAwait(false); 253await File.WriteAllTextAsync(targetsFilePath, targetsContent, Encoding.UTF8, cancellationToken).ConfigureAwait(false);
Aspire.Hosting.Maui.Tests (3)
MauiPlatformExtensionsTests.cs (3)
702File.WriteAllText(tempFile, content); 708if (File.Exists(filePath)) 710File.Delete(filePath);
Aspire.Hosting.MongoDB.Tests (3)
MongoDbFunctionalTests.cs (3)
268await File.WriteAllTextAsync(initFilePath, $$""" 291File.SetUnixFileMode(initFilePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.GroupRead | UnixFileMode.OtherRead); 366await File.WriteAllTextAsync(initFilePath, $$"""
Aspire.Hosting.MySql (2)
MySqlBuilderExtensions.cs (2)
278File.SetUnixFileMode(configStoreFilename, FileMode644); 287File.Delete(tempConfigFile);
Aspire.Hosting.MySql.Tests (3)
AddMySqlTests.cs (1)
279using var stream = File.OpenRead(volume.Source!);
MySqlFunctionalTests.cs (2)
315File.WriteAllText(Path.Combine(bindMountPath, "init.sql"), """ 402File.WriteAllText(Path.Combine(initFilesPath, "init.sql"), """
Aspire.Hosting.Oracle.Tests (4)
OracleFunctionalTests.cs (4)
120File.SetUnixFileMode(bindMountPath, MountFilePermissions); 271File.SetUnixFileMode(bindMountPath, MountFilePermissions); 278File.WriteAllText(Path.Combine(bindMountPath, "01_init.sql"), $""" 370File.WriteAllText(Path.Combine(initFilesPath, "01_init.sql"), $"""
Aspire.Hosting.PostgreSQL.Tests (2)
PostgresFunctionalTests.cs (2)
375File.WriteAllText(Path.Combine(bindMountPath, "init.sql"), """ 463File.WriteAllText(Path.Combine(initFilesPath, "init.sql"), """
Aspire.Hosting.Python (17)
PythonAppResourceBuilderExtensions.cs (10)
450if (File.Exists(Path.Combine(resource.WorkingDirectory, "Dockerfile"))) 528if (File.Exists(Path.Combine(appDirectoryFullPath, "pyproject.toml")) || 529File.Exists(Path.Combine(appDirectoryFullPath, "requirements.txt"))) 549var hasUvLock = File.Exists(uvLockPath); 658var hasRequirementsTxt = File.Exists(requirementsTxtPath); 698var hasPyprojectToml = File.Exists(pyprojectTomlPath); 1181if (File.Exists(Path.Combine(workingDirectory, "pyproject.toml"))) 1186else if (File.Exists(Path.Combine(workingDirectory, "requirements.txt"))) 1296if (File.Exists(fullPath)) 1309if (File.Exists(fullPath))
PythonVersionDetector.cs (5)
21if (File.Exists(pythonVersionFile)) 23var version = File.ReadAllText(pythonVersionFile).Trim(); 32if (File.Exists(pyprojectFile)) 34var content = File.ReadAllText(pyprojectFile); 61if (!File.Exists(pythonExecutable))
src\Shared\PathLookupHelper.cs (1)
23return FindFullPathFromPath(command, Environment.GetEnvironmentVariable("PATH"), Path.PathSeparator, File.Exists, pathExtensions);
src\Shared\RequiredCommandValidator.cs (1)
184return File.Exists(candidate) ? candidate : null;
Aspire.Hosting.Python.Tests (80)
AddPythonAppTests.cs (75)
290File.WriteAllText(scriptPath, scriptContent); 293File.WriteAllText(requirementsPath, requirementsContent); 297File.WriteAllText(dockerFilePath, 1259File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 1260File.WriteAllText(Path.Combine(projectDirectory, "uv.lock"), uvLockContent); 1261File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1283Assert.True(File.Exists(scriptDockerfilePath), "Dockerfile should be generated for script entrypoint"); 1286Assert.True(File.Exists(moduleDockerfilePath), "Dockerfile should be generated for module entrypoint"); 1289Assert.True(File.Exists(executableDockerfilePath), "Dockerfile should be generated for executable entrypoint"); 1291var scriptDockerfileContent = File.ReadAllText(scriptDockerfilePath); 1292var moduleDockerfileContent = File.ReadAllText(moduleDockerfilePath); 1293var executableDockerfileContent = File.ReadAllText(executableDockerfilePath); 1324File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 1326File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1348Assert.True(File.Exists(scriptDockerfilePath), "Dockerfile should be generated for script entrypoint"); 1351Assert.True(File.Exists(moduleDockerfilePath), "Dockerfile should be generated for module entrypoint"); 1354Assert.True(File.Exists(executableDockerfilePath), "Dockerfile should be generated for executable entrypoint"); 1356var scriptDockerfileContent = File.ReadAllText(scriptDockerfilePath); 1357var moduleDockerfileContent = File.ReadAllText(moduleDockerfilePath); 1358var executableDockerfileContent = File.ReadAllText(executableDockerfilePath); 1642File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 1643File.WriteAllText(Path.Combine(projectDirectory, "uv.lock"), uvLockContent); 1644File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1660Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated"); 1662var dockerfileContent = File.ReadAllText(dockerfilePath); 1688File.WriteAllText(Path.Combine(projectDirectory, "requirements.txt"), requirementsContent); 1689File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1701Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated for non-UV Python app"); 1703var dockerfileContent = File.ReadAllText(dockerfilePath); 1737File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1738File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 1750Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated for non-UV Python app"); 1752var dockerfileContent = File.ReadAllText(dockerfilePath); 1769File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1781Assert.True(File.Exists(dockerfilePath), "Dockerfile should be generated for Python app"); 1783var dockerfileContent = File.ReadAllText(dockerfilePath); 1802File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 1803File.WriteAllText(Path.Combine(projectDirectory, ".python-version"), pythonVersionContent); 1817Assert.True(File.Exists(scriptDockerfilePath), "Dockerfile should be generated for script entrypoint"); 1820Assert.True(File.Exists(moduleDockerfilePath), "Dockerfile should be generated for module entrypoint"); 1823Assert.True(File.Exists(executableDockerfilePath), "Dockerfile should be generated for executable entrypoint"); 1825var scriptDockerfileContent = File.ReadAllText(scriptDockerfilePath); 1826var moduleDockerfileContent = File.ReadAllText(moduleDockerfilePath); 1827var executableDockerfileContent = File.ReadAllText(executableDockerfilePath); 1852File.WriteAllText(scriptPath, "print('Hello')"); 1856File.WriteAllText(pyprojectPath, "[project]\nname = \"test\""); 1886File.WriteAllText(scriptPath, "print('Hello')"); 1890File.WriteAllText(requirementsPath, "requests==2.31.0"); 1921File.WriteAllText(scriptPath, "print('Hello')"); 1925File.WriteAllText(pyprojectPath, "[project]\nname = \"test\""); 1927File.WriteAllText(requirementsPath, "requests==2.31.0"); 1951File.WriteAllText(scriptPath, "print('Hello')"); 1975File.WriteAllText(scriptPath, "print('Hello')"); 1998File.WriteAllText(scriptPath, "print('Hello')"); 2002File.WriteAllText(requirementsPath, "requests"); 2026File.WriteAllText(scriptPath, "print('Hello')"); 2030File.WriteAllText(requirementsPath, "requests"); 2055File.WriteAllText(scriptPath, "print('Hello')"); 2083File.WriteAllText(scriptPath, "print('Hello')"); 2087File.WriteAllText(requirementsPath, "requests"); 2126File.WriteAllText(scriptPath, "print('Hello')"); 2129File.WriteAllText(requirementsPath, "requests"); 2156File.WriteAllText(scriptPath, "print('Hello')"); 2159File.WriteAllText(requirementsPath, "requests"); 2190File.WriteAllText(scriptPath, "print('Hello')"); 2193File.WriteAllText(requirementsPath, "requests"); 2226File.WriteAllText(scriptPath, "print('Hello')"); 2229File.WriteAllText(requirementsPath, "requests"); 2256File.WriteAllText(scriptPath, "print('Hello')"); 2259File.WriteAllText(requirementsPath, "requests"); 2288File.WriteAllText(scriptPath, "print('Hello')"); 2291File.WriteAllText(requirementsPath, "requests"); 2320File.WriteAllText(scriptPath, "print('Hello')"); 2323File.WriteAllText(requirementsPath, "requests"); 2356File.WriteAllText(scriptPath, "print('Hello')");
AddUvicornAppTests.cs (5)
57File.WriteAllText(Path.Combine(projectDirectory, "pyproject.toml"), pyprojectContent); 58File.WriteAllText(Path.Combine(projectDirectory, "uv.lock"), uvLockContent); 59File.WriteAllText(Path.Combine(projectDirectory, "main.py"), scriptContent); 88Assert.True(File.Exists(appDockerfilePath), "Dockerfile should be generated for script entrypoint"); 90var scriptDockerfileContent = File.ReadAllText(appDockerfilePath);
Aspire.Hosting.Redis.Tests (1)
RedisFunctionalTests.cs (1)
478File.SetUnixFileMode(bindMountPath, MountFilePermissions);
Aspire.Hosting.SqlServer.Tests (1)
SqlServerFunctionalTests.cs (1)
171File.SetUnixFileMode(bindMountPath, BindMountPermissions);
Aspire.Hosting.Testing (2)
DistributedApplicationFactory.cs (2)
353if (!File.Exists(launchSettingsFilePath)) 358using var stream = File.OpenRead(launchSettingsFilePath);
Aspire.Hosting.Testing.Tests (3)
TestingBuilderTests.cs (1)
55Assert.True(File.Exists(testProjectAssemblyPath), $"TestProject.AppHost.dll not found at {testProjectAssemblyPath}.");
tests\Aspire.Hosting.Tests\Utils\MSBuildUtils.cs (1)
13while (directory != null && !Directory.Exists(Path.Combine(directory, ".git")) && !File.Exists(Path.Combine(directory, ".git")))
tests\Shared\DistributedApplicationTestingBuilderExtensions.cs (1)
129var content = await File.ReadAllTextAsync(logFile, cancellationToken);
Aspire.Hosting.Tests (108)
ApplicationModel\Docker\DockerfileBuildAnnotationTests.cs (13)
87Assert.False(File.Exists(dockerfilePath)); 91if (File.Exists(dockerfilePath)) 93File.Delete(dockerfilePath); 121Assert.True(File.Exists(dockerfilePath)); 122var actualContent = await File.ReadAllTextAsync(dockerfilePath); 127if (File.Exists(dockerfilePath)) 129File.Delete(dockerfilePath); 163Assert.True(File.Exists(dockerfilePath)); 167if (File.Exists(dockerfilePath)) 169File.Delete(dockerfilePath); 206Assert.True(File.Exists(dockerfilePath)); 210if (File.Exists(dockerfilePath)) 212File.Delete(dockerfilePath);
AspireStoreTests.cs (8)
67Assert.True(File.Exists(filePath)); 68Assert.Equal("Test content", File.ReadAllText(filePath)); 78File.WriteAllText(tempFilename, "Test content"); 81Assert.True(File.Exists(filePath)); 82Assert.Equal("Test content", File.ReadAllText(filePath)); 86File.Delete(tempFilename); 110File.WriteAllText(filePath, "updated"); 114var content2 = File.ReadAllText(filePath2);
Backchannel\AuxiliaryBackchannelTests.cs (1)
39Assert.True(File.Exists(service.SocketPath));
Dashboard\DashboardLifecycleHookTests.cs (19)
203File.Delete(tempDir); 212File.WriteAllText(dashboardDll, "mock dll content"); 235File.WriteAllText(runtimeConfig, JsonSerializer.Serialize(originalConfig, new JsonSerializerOptions { WriteIndented = true })); 260Assert.True(File.Exists((string)args[2]), "Custom runtime config file should exist"); 264var customConfigContent = File.ReadAllText((string)args[2]); 296File.Delete(tempDir); 306File.WriteAllText(dashboardExe, "mock exe content"); 307File.WriteAllText(dashboardDll, "mock dll content"); 323File.WriteAllText(runtimeConfig, JsonSerializer.Serialize(originalConfig, new JsonSerializerOptions { WriteIndented = true })); 345Assert.True(File.Exists((string)args[2]), "Custom runtime config file should exist"); 368File.Delete(tempDir); 378File.WriteAllText(dashboardExe, "mock exe content"); 379File.WriteAllText(dashboardDll, "mock dll content"); 395File.WriteAllText(runtimeConfig, JsonSerializer.Serialize(originalConfig, new JsonSerializerOptions { WriteIndented = true })); 417Assert.True(File.Exists((string)args[2]), "Custom runtime config file should exist"); 440File.Delete(tempDir); 449File.WriteAllText(dashboardDll, "mock dll content"); 465File.WriteAllText(runtimeConfig, JsonSerializer.Serialize(originalConfig, new JsonSerializerOptions { WriteIndented = true })); 487Assert.True(File.Exists((string)args[2]), "Custom runtime config file should exist");
FileSystemServiceTests.cs (24)
70Assert.True(File.Exists(tempFile.Path)); 81Assert.True(File.Exists(tempFile.Path)); 92Assert.True(File.Exists(path)); 96Assert.False(File.Exists(path)); 107Assert.True(File.Exists(filePath)); 112Assert.False(File.Exists(filePath)); 154Assert.True(File.Exists(extractedPath)); 157File.Delete(extractedPath); 193Assert.True(File.Exists(tempFile1.Path)); 194Assert.True(File.Exists(tempFile2.Path)); 225Assert.True(File.Exists(filePath)); 231Assert.False(File.Exists(filePath)); 245Assert.True(File.Exists(filePath)); 252Assert.True(File.Exists(filePath)); 256File.Delete(filePath); 287Assert.True(File.Exists(filePath)); 293Assert.True(File.Exists(filePath)); 296File.Delete(filePath); 320Assert.False(File.Exists(file1Path)); 322Assert.True(File.Exists(file2Path)); 328Assert.False(File.Exists(file2Path)); 358Assert.False(File.Exists(filePath)); 374Assert.True(File.Exists(filePath)); 380Assert.False(File.Exists(filePath));
MSBuildTests.cs (16)
25File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 54File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"), 82File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 110File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"), 121var appHostMetadata = await File.ReadAllTextAsync(Path.Combine(metadataDirectory, "_AppHost.ProjectMetadata.g.cs")); 122var appMetadata = await File.ReadAllTextAsync(Path.Combine(metadataDirectory, "App.ProjectMetadata.g.cs")); 149File.WriteAllText(Path.Combine(basePath, "Directory.Build.props"), 159File.WriteAllText(Path.Combine(basePath, "Directory.Build.targets"), 177File.WriteAllText(Path.Combine(libraryDirectory, $"{name}.csproj"), 189File.WriteAllText(Path.Combine(libraryDirectory, "Class1.cs"), 204File.WriteAllText(Path.Combine(appDirectory, $"{name}.csproj"), 215File.WriteAllText(Path.Combine(appDirectory, "Program.cs"), 271File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 300File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"), 330File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.csproj"), 359File.WriteAllText(Path.Combine(appHostDirectory, "AppHost.cs"),
ProjectResourceTests.cs (3)
60await File.WriteAllTextAsync(projectFilePath, csProjContent).DefaultTimeout(); 63await File.WriteAllTextAsync(launchSettingsFilePath, launchSettingsContent).DefaultTimeout(); 833var dockerFileContent = File.ReadAllText(dockerfilePath);
PublishAsDockerfileTests.cs (1)
455File.WriteAllText(Path.Join(tempDir.Path, "Dockerfile"), "this does not matter");
Publishing\ResourceContainerImageManagerTests.cs (2)
771if (File.Exists(tempFile)) 773File.Delete(tempFile);
Schema\SchemaTests.cs (4)
62File.WriteAllText(tempDockerfilePath, "does not need to be valid dockerfile content here"); 74File.WriteAllText(tempDockerfilePath, "does not need to be valid dockerfile content here"); 92File.WriteAllText(tempDockerfilePath, "does not need to be valid dockerfile content here"); 123File.WriteAllText(tempDockerfilePath, "does not need to be valid dockerfile content here");
SecretsStoreTests.cs (5)
79if (!File.Exists(manager.FilePath)) 96if (File.Exists(filePath)) 98File.Delete(filePath); 105if (File.Exists(userSecretsPath)) 107File.Delete(userSecretsPath);
tests\Shared\DistributedApplicationTestingBuilderExtensions.cs (1)
129var content = await File.ReadAllTextAsync(logFile, cancellationToken);
UserSecretsParameterDefaultTests.cs (9)
68if (File.Exists(userSecretsPath)) 70File.Delete(userSecretsPath); 79File.WriteAllText(userSecretsPath, secretsFileContents, Encoding.UTF8); 339if (File.Exists(manager.FilePath)) 341var json = File.ReadAllText(manager.FilePath); 363if (File.Exists(filePath)) 365File.Delete(filePath); 372if (File.Exists(userSecretsPath)) 374File.Delete(userSecretsPath);
Utils\DockerfileUtils.cs (1)
53await File.WriteAllTextAsync(tempDockerfilePath, dockerfileContent);
Utils\MSBuildUtils.cs (1)
13while (directory != null && !Directory.Exists(Path.Combine(directory, ".git")) && !File.Exists(Path.Combine(directory, ".git")))
Aspire.Hosting.Yarp (1)
YarpJsonConfigGeneratorBuilder.cs (1)
66return await File.ReadAllTextAsync(_configFilePath, ct).ConfigureAwait(false);
Aspire.Hosting.Yarp.Tests (2)
YarpConfigGeneratorTests.cs (2)
294Assert.True(File.Exists(composeFile), "Docker Compose file was not created."); 296var content = await File.ReadAllTextAsync(composeFile);
Aspire.Playground.Tests (1)
src\Shared\PathLookupHelper.cs (1)
23return FindFullPathFromPath(command, Environment.GetEnvironmentVariable("PATH"), Path.PathSeparator, File.Exists, pathExtensions);
Aspire.RuntimeIdentifier.Tool (1)
Program.cs (1)
49if (!File.Exists(rgp))
Aspire.Templates.Tests (33)
AppHostTemplateTests.cs (2)
30var newContents = AppHostPackageReferenceRegex().Replace(File.ReadAllText(projectPath), @"$1""8.1.0"""); 32File.WriteAllText(projectPath, newContents);
BuildAndRunTemplateTests.cs (8)
70var projectContents = File.ReadAllText(projectName); 74File.WriteAllText( 107File.WriteAllText(cpmFilePath, cpmContent); 134var projectContents = File.ReadAllText(projectName); 140File.WriteAllText( 151File.WriteAllText( 234var projectContents = File.ReadAllText(projectName); 238File.WriteAllText(projectName, modifiedContents);
TemplateTestsBase.cs (5)
75Assert.True(File.Exists(testProjectPath), $"Expected tests project file at {testProjectPath}"); 104var newContents = File.ReadAllText(projectPath) 106File.WriteAllText(projectPath, newContents); 124foreach (var line in File.ReadAllLines(testCsPath)) 142File.WriteAllText(testCsPath, sb.ToString());
tests\Shared\Playwright\PlaywrightProvider.cs (2)
20if (!string.IsNullOrEmpty(browserPath) && !File.Exists(browserPath)) 31if (File.Exists(probePath))
tests\Shared\Playwright\TestUtils.cs (1)
14if (Directory.Exists(Path.Combine(repoRoot.FullName, ".git")) || File.Exists(Path.Combine(repoRoot.FullName, ".git")))
tests\Shared\TemplatesTesting\AspireProject.cs (9)
65File.WriteAllText(Path.Combine(dir, "Directory.Build.props"), "<Project />"); 66File.WriteAllText(Path.Combine(dir, "Directory.Build.targets"), "<Project />"); 73File.Copy(srcNuGetConfigPath, targetNuGetConfigPath); 107File.WriteAllText(Path.Combine(rootDir, "Directory.Build.props"), "<Project />"); 108File.WriteAllText(Path.Combine(rootDir, "Directory.Build.targets"), "<Project />"); 131var csprojContent = File.ReadAllText(csprojPath); 151File.Copy(Path.Combine(BuildEnvironment.TestAssetsPath, "EndPointWriterHook_cs"), Path.Combine(project.AppHostProjectDirectory, "EndPointWriterHook.cs")); 153string programCs = File.ReadAllText(programCsPath); 156File.WriteAllText(programCsPath, programCs);
tests\Shared\TemplatesTesting\BuildEnvironment.cs (2)
101.FirstOrDefault(File.Exists); 124.FirstOrDefault(File.Exists);
tests\Shared\TemplatesTesting\TemplateCustomHive.cs (4)
18public string CustomHiveDirectory => File.Exists(_stampFilePath) 37if (BuildEnvironment.IsRunningOnCI && File.Exists(_stampFilePath)) 51if (File.Exists(_stampFilePath)) 80File.WriteAllText(_stampFilePath, "");
Aspire.TestUtilities (1)
src\Shared\PathLookupHelper.cs (1)
23return FindFullPathFromPath(command, Environment.GetEnvironmentVariable("PATH"), Path.PathSeparator, File.Exists, pathExtensions);
AzureSearch.ApiService (1)
Program.cs (1)
148using var openStream = File.OpenRead(hotelsJson);
blazor-devserver (1)
Server\Program.cs (1)
30name = !File.Exists(name) ? Path.ChangeExtension(applicationPath, ".StaticWebAssets.xml") : name;
BoundTreeGenerator (1)
Program.cs (1)
59using (var outfile = new StreamWriter(File.Open(outfilename, FileMode.Create), Encoding.UTF8))
BuildActionTelemetryTable (2)
Program.cs (2)
69File.WriteAllText(filepath, datatable); 82File.WriteAllText(filepath, descriptionMap);
BuildBoss (7)
CompilerNuGetCheckerUtil.cs (2)
96var publishDataRoot = JObject.Parse(File.ReadAllText(publishDataPath)); 331using var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
OptProfCheckerUtil.cs (4)
37if (!File.Exists(OptProfFile)) 42var content = File.ReadAllText(OptProfFile); 66if (!File.Exists(vsixFullPath)) 101using (var archive = new ZipArchive(File.Open(vsixFullPath, FileMode.Open), ZipArchiveMode.Read))
Program.cs (1)
88while (dir != null && !File.Exists(Path.Combine(dir, "global.json")))
BuildValidator (14)
CompilationDiff.cs (7)
157var originalBytes = File.ReadAllBytes(assemblyInfo.FilePath); 219File.WriteAllText(Path.Combine(debugPath, "error.txt"), MiscErrorMessage); 295File.WriteAllText(Path.Combine(debugPath, scriptName), $@"code --diff (Join-Path $PSScriptRoot ""{originalFilePath}"") (Join-Path $PSScriptRoot ""{rebuildFilePath}"")"); 306using var file = File.OpenWrite(sourceFilePath); 325File.WriteAllBytes(assemblyFilePath, buildInfo.AssemblyBytes); 345using var pdbXmlStream = File.Create(buildDataFiles.PdbXmlFilePath); 366using var tempFile = File.OpenWrite(filePath);
LocalReferenceResolver.cs (1)
130File.OpenRead(assemblyInfo.FilePath),
LocalSourceResolver.cs (2)
37if (File.Exists(onDiskPath)) 48using var fileStream = File.OpenRead(onDiskPath);
Program.cs (3)
315using var originalPeReader = new PEReader(File.OpenRead(assemblyInfo.FilePath)); 320filePath => File.Exists(filePath) ? new MemoryStream(File.ReadAllBytes(filePath)) : null,
Util.cs (1)
17using var stream = File.OpenRead(filePath);
CatalogService (1)
CatalogApi.cs (1)
42if (!File.Exists(path))
ClientSample (1)
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
CodeGenerator (3)
Program.cs (3)
63var existingContent = File.Exists(path) ? File.ReadAllText(path) : ""; 66File.WriteAllText(path, content);
CodeStyleConfigFileGenerator (2)
Program.cs (2)
92File.WriteAllText(configFilePath, text); 206File.WriteAllText(fileWithPath, $@"<Project>{GetTargetContents(language)}
ConfigurationSchemaGenerator (1)
ConfigSchemaGenerator.cs (1)
41File.WriteAllText(outputFile, schema);
ConfigurationSchemaGenerator.Tests (3)
GeneratorTests.cs (3)
42private static readonly SyntaxTree s_attributesSyntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText("ConfigurationSchemaAttributes.cs")); 1602var actual = File.ReadAllText(outputPath).ReplaceLineEndings(); 1603var baseline = File.ReadAllText(Path.Combine("Baselines", "IntegrationTest.baseline.json")).ReplaceLineEndings();
Crossgen2Tasks (13)
PrepareForReadyToRunCompilation.cs (1)
120!string.IsNullOrEmpty(diaSymReaderPath) && File.Exists(diaSymReaderPath);
ResolveReadyToRunCompilers.cs (4)
389return File.Exists(_crossgenTool.ToolPath) && File.Exists(_crossgenTool.ClrJitPath); 417if (!File.Exists(_crossgen2Tool.ClrJitPath)) 424return File.Exists(_crossgen2Tool.ToolPath);
RunReadyToRunCompiler.cs (8)
103if (!File.Exists(Crossgen2Tool.ItemSpec)) 109if (!string.IsNullOrEmpty(hostPath) && !File.Exists(hostPath)) 117if (!File.Exists(jitPath)) 151if (!File.Exists(CrossgenTool.ItemSpec)) 156if (!File.Exists(CrossgenTool.GetMetadata(MetadataKeys.JitPath))) 169if (!string.IsNullOrEmpty(DiaSymReader) && !File.Exists(DiaSymReader)) 181if (!File.Exists(_outputR2RImage)) 194if (!File.Exists(_inputAssembly))
csc (6)
src\Compilers\Shared\BuildServerConnection.cs (4)
439if (!File.Exists(processFilePath)) 529if (!File.Exists(serverInfo.processFilePath)) 821if (!File.Exists(FilePath)) 851File.Delete(FilePath);
src\Compilers\Shared\RuntimeHostInfo.cs (2)
43var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 91if (File.Exists(filePath))
CSharpErrorFactsGenerator (2)
Program.cs (2)
44foreach (var line in File.ReadAllLines(inputPath).Select(l => l.Trim())) 137File.WriteAllText(outputPath, outputText.ToString(), Encoding.UTF8);
CSharpSyntaxGenerator (3)
Program.cs (3)
72if (!File.Exists(inputFile)) 106using var outFile = new StreamWriter(File.Open(outputMainFile, FileMode.Create), Encoding.UTF8); 177using var outFile = new StreamWriter(File.Open(outputFile, FileMode.Create), Encoding.UTF8);
dotnet-dev-certs (22)
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
dotnet-getdocument (9)
Commands\InvokeCommand.cs (8)
66File.Copy(executableSource, executable, overwrite: true); 69if (File.Exists(configPath)) 71File.Copy(configPath, executable + ".config", overwrite: true); 94if (!string.IsNullOrEmpty(projectAssetsFile) && File.Exists(projectAssetsFile)) 96using var reader = new JsonTextReader(File.OpenText(projectAssetsFile)); 110if (File.Exists(runtimeConfigPath)) 168File.Delete(executable); 176File.Delete(executable + ".config");
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
dotnet-openapi (9)
Commands\AddFileCommand.cs (1)
54return File.Exists(GetFullPath(file));
Commands\BaseCommand.cs (6)
102if (!File.Exists(project)) 137return File.Exists(Path.GetFullPath(file)) && file.EndsWith(".csproj", StringComparison.Ordinal); 350if (!File.Exists(filePath)) 515var destinationExists = File.Exists(destinationPath); 531using (var destinationStream = File.OpenRead(destinationPath)) 575File.Delete(destinationPath);
Commands\RemoveCommand.cs (1)
44File.Delete(GetFullPath(file));
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
dotnet-razorpagegenerator (3)
Program.cs (3)
44File.WriteAllText(result.FilePath, result.GeneratedCode); 195var cshtmlContent = File.ReadAllText(_source.PhysicalPath); 214var includeFileContent = File.ReadAllText(System.IO.Path.Combine(basePath, includeFileName));
dotnet-sql-cache (1)
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
dotnet-svcutil.xmlserializer (9)
Microsoft\Tools\ServiceModel\SvcUtil\CommandLineParser.cs (1)
209if (File.Exists(potentialPath))
Microsoft\Tools\ServiceModel\SvcUtil\XmlSerializerGenerator.cs (8)
70if (File.Exists(codePath)) 72File.Delete(codePath); 75using (FileStream fs = File.Create(codePath)) 90if (!success && toDeleteFile && File.Exists(codePath)) 92File.Delete(codePath); 100if (File.Exists(sgenSource)) 101File.Delete(sgenSource); 111File.Copy(codePath, sourceFilePath, true);
dotnet-svcutil.xmlserializer.IntegrationTests (4)
SvcutilTests.cs (4)
22Assert.False(File.Exists(outputFile)); 25if (File.Exists(smassemblypath)) 28Assert.True(File.Exists(outputFile)); 29File.Delete(outputFile);
dotnet-svcutil-lib (46)
Bootstrapper\SvcutilBootstrapper.cs (1)
171File.WriteAllText(programFilePath, s_programClass);
CodeSerializer.cs (2)
79if (File.Exists(_outputFilePath)) 81File.Delete(_outputFilePath);
CommandProcessorOptions.cs (4)
439if (!IsUpdateOperation && this.ToolContext <= OperationalContext.Global && File.Exists(filePath)) 526if (!PathHelper.IsUnderDirectory(svcutilParmasFile, projectDirInfo, out paramsFilePath, out fileRelPath) || !File.Exists(paramsFilePath)) 529if (!PathHelper.IsUnderDirectory(wcfcsParamsFile, projectDirInfo, out paramsFilePath, out fileRelPath) || !File.Exists(paramsFilePath)) 700if (File.Exists(projectFullPath))
FrameworkFork\Microsoft.CodeDom\Compiler\CodeCompiler.cs (2)
121using (Stream str = File.OpenRead(fileName)) { } 215using (Stream str = File.OpenRead(fileName)) { }
FrameworkFork\Microsoft.CodeDom\Compiler\TempFiles.cs (1)
292File.Delete(fileName);
FrameworkFork\Microsoft.CodeDom\Microsoft\CSharpCodeProvider.cs (4)
3938File.Delete(options.OutputAssembly); 3954using (FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read, share)) 4055using (Stream str = File.OpenRead(fileName)) { } 4125using (Stream str = File.OpenRead(fileName)) { }
FrameworkFork\Microsoft.Xml\Xml\Core\XmlReader.cs (1)
1895} while (File.Exists(dumpFileName));
FrameworkFork\Microsoft.Xml\Xml\schema\GenerateConverter.cs (1)
1050public AutoGenWriter(string fileName, string regionName) : this(File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite), regionName)
FrameworkFork\System.Web.Services\Services\Description\ServiceDescription.cs (2)
376StreamReader reader = new StreamReader(File.OpenRead(fileName), detectEncodingFromByteOrderMarks: true); 435StreamWriter writer = new StreamWriter(File.OpenWrite(fileName));
Metadata\MetadataDocumentLoader.cs (5)
527if (!File.Exists(fullFileName)) 535if (!File.Exists(fullFileName) && !string.IsNullOrWhiteSpace(specNamespace)) 544if (!File.Exists(fullFileName) && !Path.IsPathRooted(schemaLocation)) 548if (!File.Exists(fullFileName)) 555if (File.Exists(fullFileName))
Metadata\MetadataDocumentSaver.cs (1)
71var fileInfo = this.MetadataFiles.FirstOrDefault(fi => File.Exists(fi.FilePath));
Metadata\MetadataFileNameManager.cs (1)
183if (File.Exists(filePath))
Shared\MSBuildProj.cs (10)
147var project = await ParseAsync(File.ReadAllText(filePath), filePath, logger, cancellationToken).ConfigureAwait(false); 154var project = await ParseAsync(File.ReadAllText(filePath), filePath, logger, cancellationToken, tfMoniker).ConfigureAwait(false); 322if (fullPath == null || !File.Exists(fullPath)) 396if (File.Exists(fullPath)) 412project = await ParseAsync(File.ReadAllText(fullPath), fullPath, logger, cancellationToken).ConfigureAwait(false); 701using (StreamWriter writer = File.CreateText(this.FullPath)) 798if (File.Exists(assetsFile) && !(this.TargetFramework.Contains("-") && !this.TargetFramework.ToLower().Contains("windows"))) 883if (File.Exists(depsFile)) 890using (var stream = File.OpenRead(depsFile)) 915if (File.Exists(dependency.FullPath) && !assemblyDependencies.Contains(dependency))
Shared\Options\ApplicationOptions.cs (2)
140jsonText = File.ReadAllText(fileInfo.FullName); 173File.WriteAllText(filePath, this.Json);
Shared\ProjectPropertyResolver.cs (2)
149while (dotnetDir != null && !(File.Exists(Path.Combine(dotnetDir, "dotnet")) || File.Exists(Path.Combine(dotnetDir, "dotnet.exe"))))
Shared\Utilities\PathHelper.cs (2)
209if (File.Exists(filePath)) 216File.Copy(filePath, dstFilePath, overwrite: true);
Shared\Utilities\RuntimeEnvironmentHelper.cs (4)
47if (!File.Exists(Path.Combine(destinationDirectory, "global.json"))) 53if (!File.Exists(Path.Combine(destinationDirectory, "nuget.config"))) 73if (File.Exists(nugetConfigPath)) 79using (var stream = File.Open(nugetConfigPath, FileMode.Open, FileAccess.ReadWrite))
Tool.cs (1)
145if (!File.Exists(options.OutputFile.FullName))
dotnet-svcutil-lib.Tests (52)
E2ETests.cs (9)
174if (!File.Exists(wsdlFile)) 180Assert.True(File.Exists(wsdlFile), $"{wsdlFile} not initialized!"); 226if (!File.Exists(assemblyPath)) 238Assert.True(File.Exists(binProjPath), $"{nameof(binProjPath)} not initialized!"); 239Assert.True(File.Exists(libProjPath), $"{nameof(libProjPath)} not initialized!"); 369Assert.True(File.Exists(srcParamsFilePath), $"{nameof(srcParamsFilePath)} not initialized!"); 374File.Copy(f, Path.Combine(this_TestCaseProject.DirectoryPath, Path.GetFileName(f))); 383File.WriteAllText(dstParamsFile, File.ReadAllText(dstParamsFile).Replace("$testCasesPath$", g_TestCasesDir.Replace("\\", "/")));
FixupUtil.cs (2)
107var originalText = System.IO.File.ReadAllText(fileName); 112System.IO.File.WriteAllText(fileName, updatedText);
GlobalToolTests.cs (4)
99File.Copy(Path.Combine(g_TestCasesDir, "FullFramework", "FullFramework.cs"), Path.Combine(this_TestCaseOutputDir, "FullFramework.cs"), true); 100File.Copy(Path.Combine(g_TestCasesDir, "FullFramework", "FullFramework.csproj"), Path.Combine(this_TestCaseOutputDir, "FullFramework.csproj"), true); 127File.Copy(Path.Combine(g_TestCasesDir, this_TestCaseName, testCaseName, "Program.cs"), Path.Combine(this_TestCaseOutputDir, "Program.cs"), true); 128File.Copy(Path.Combine(g_TestCasesDir, this_TestCaseName, testCaseName, $"{testCaseName}.csproj"), Path.Combine(this_TestCaseOutputDir, $"{testCaseName}.csproj"), true);
ProjectUtils.cs (9)
28if (forceNew && File.Exists(filePath)) 30File.Delete(filePath); 31if (File.Exists(dstProgramFile)) 32File.Delete(dstProgramFile); 36if (File.Exists(filePath)) 51File.Move(srcProgramFile, dstProgramFile); 87Assert.True(File.Exists(project?.FullPath), $"{nameof(project)} is not initialized!"); 175Assert.True(File.Exists(project?.FullPath), $"{nameof(project)} is not initialized!"); 181File.Copy(srcParamsFile, dstParamsFile);
TestInit.cs (20)
60File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.props"), "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" />"); 61File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.targets"), "<Project></Project>"); 95if (!File.Exists(filePath)) 115File.Copy(project.FullPath, projectPath); 116File.Copy(srcProgramPath, programPath); 118File.WriteAllText(programPath, File.ReadAllText(programPath) 167Assert.True(File.Exists(g_StarterProject.FullPath), $"{nameof(g_StarterProject)} is not initialized!"); 173File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.props"), "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" />"); 174File.WriteAllText(Path.Combine(g_TestOutputDir, "Directory.Build.targets"), "<Project></Project>"); 268if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists(Path.Combine(linuxBaselinePath, Path.GetFileName(this_TestCaseLogFile)))) 335File.WriteAllText(this.this_TestCaseLogFile, logText); 354if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists(Path.Combine(linuxBaselinePath, Path.GetFileName(this_TestCaseLogFile)))) 430File.Copy(generated, expected); 458File.WriteAllText(scriptPath, cmdStr.ToString()); 472fileLines1.AddRange(File.ReadAllLines(baselineFile)); 473fileLines2.AddRange(File.ReadAllLines(generatedFile)); 590Assert.True(rootSolutionFolder != null && File.Exists(rootSolutionFolder), $"Unable to find dotnet-svcutil.sln file, current dir: {parentDir}"); 606File.WriteAllText(Path.Combine(directory, "global.json"), globalConfig); 624File.WriteAllText(Path.Combine(g_TestOutputDir, "nuget.config"), nugetConfigText.Replace("$svcutilTestFeed$", g_SvcutilNugetFeed));
UnitTest.cs (8)
225File.Copy(Path.Combine(g_TestCasesDir, "wsdl", "Simple.wsdl"), Path.Combine(this_TestGroupOutputDir, "wsdl", "Simple.wsdl")); 271File.WriteAllText(this_TestCaseLogFile, this_FixupUtil.ReplaceText(log)); 309File.WriteAllText(this_TestCaseLogFile, this_FixupUtil.ReplaceText(log)); 331File.Copy(jsonFileSrcPath, jsonFileDstPath); 332File.WriteAllText(jsonFileDstPath, File.ReadAllText(jsonFileDstPath).Replace("$testCaseProject$", this_TestCaseProject.FullPath.Replace("\\", "/"))); 348var jsonText = File.ReadAllText(jsonFileSrcPath); 354File.WriteAllText(outJsonFile, options.Json);
dotnet-user-jwts (12)
Helpers\DevJwtCliHelpers.cs (2)
58else if (!File.Exists(Path.Combine(Path.GetDirectoryName(projectPath), appsettingsFile))) 77if (File.Exists(launchSettingsFilePath))
Helpers\JwtStore.cs (2)
28if (File.Exists(_filePath)) 46File.Move(tempFilename, _filePath, overwrite: true);
Helpers\SigningKeysHandler.cs (1)
66if (File.Exists(secretsFilePath))
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\Tools\Shared\SecretsHelpers\MsBuildProjectFinder.cs (1)
47if (!File.Exists(projectPath))
src\Tools\Shared\SecretsHelpers\ProjectIdResolver.cs (5)
113if (!File.Exists(outputFile)) 119var id = File.ReadAllText(outputFile)?.Trim(); 144var targetPath = searchPaths.Select(p => Path.Combine(p, "SecretManager.targets")).FirstOrDefault(File.Exists); 157if (File.Exists(file)) 159File.Delete(file);
dotnet-user-secrets (9)
Internal\SecretsStore.cs (2)
86File.Move(tempFilename, _secretsFilePath, overwrite: true); 89File.WriteAllText(_secretsFilePath, contents.ToString(), Encoding.UTF8);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\Tools\Shared\SecretsHelpers\MsBuildProjectFinder.cs (1)
47if (!File.Exists(projectPath))
src\Tools\Shared\SecretsHelpers\ProjectIdResolver.cs (5)
113if (!File.Exists(outputFile)) 119var id = File.ReadAllText(outputFile)?.Trim(); 144var targetPath = searchPaths.Select(p => Path.Combine(p, "SecretManager.targets")).FirstOrDefault(File.Exists); 157if (File.Exists(file)) 159File.Delete(file);
FilesWebSite (1)
Controllers\DownloadFilesController.cs (1)
59var fileInfo = System.IO.File.CreateSymbolicLink(symlink, path);
GenerateAnalyzerNuspec (6)
Program.cs (6)
159if (File.Exists(resourceAssemblyFullPath)) 192if (File.Exists(fileWithPath)) 269if (File.Exists(fileWithPath)) 278if (File.Exists(fileWithPath)) 287if (File.Exists(fileWithPath)) 298File.WriteAllText(nuspecFile, result.ToString());
GenerateDocumentationAndConfigFiles (21)
Program.cs (16)
275if (!File.Exists(path)) 436File.WriteAllText(fileWithPath, fileContents); 457File.WriteAllText(fileWithPath, fileContents); 610File.WriteAllText(fileWithPath, builder.ToString()); 787actualContent = File.ReadAllLines(fileWithPath); 834File.WriteAllText(fileWithPath, builder.ToString()); 873if (!File.Exists(assemblyPath)) 906var shippedFileExists = File.Exists(shippedFile); 907var unshippedFileExists = File.Exists(unshippedFile); 930using var fileStream = File.OpenRead(shippedFile); 940using var fileStreamUnshipped = File.OpenRead(unshippedFile); 1113File.WriteAllText(rulesetFilePath, text); 1178File.WriteAllText(editorconfigFilePath, text); 1363string actual = File.ReadAllText(fileWithPath); 1400File.WriteAllText(configFilePath, text); 1611File.WriteAllText(fileWithPath, fileContents);
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
GenerateRulesMissingDocumentation (3)
Program.cs (3)
53actualContent = File.ReadAllLines(fileWithPath); 100File.WriteAllText(fileWithPath, builder.ToString()); 148if (!File.Exists(path))
GetDocument.Insider (5)
Commands\GetDocumentCommand.cs (1)
94if (!File.Exists(assemblyPath))
Commands\GetDocumentCommandWorker.cs (3)
309var stream = File.Create(_context.FileListPath); 384using var outStream = File.Create(filePath); 389File.Delete(filePath);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
HelixTestRunner (10)
ProcessUtil.cs (2)
62if (!File.Exists($"{Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT")}/dotnet-dump") && 63!File.Exists($"{Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT")}/dotnet-dump.exe"))
TestRunner.cs (8)
62if (!File.Exists("xunit.runner.json")) 64File.Copy("default.runner.json", "xunit.runner.json"); 130File.Move(filename, backupFilename); 165File.Move(backupFilename, filename); 292if (File.Exists("TestResults/TestResults.xml")) 295File.Copy("TestResults/TestResults.xml", "testResults.xml", overwrite: true); 317File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, logName)); 331File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, fileName));
IdeBenchmarks (3)
FormatterBenchmarks.cs (2)
41var text = File.ReadAllText(path); 54var text = File.ReadAllText(path);
InheritanceMargin\InheritanceMarginServiceBenchmarks.cs (1)
38if (!File.Exists(solutionPath))
IdeCoreBenchmarks (12)
ClassificationBenchmarks.cs (1)
57if (!File.Exists(solutionPath))
CSharpIdeAnalyzerBenchmarks.cs (1)
39if (!File.Exists(_solutionPath))
FindReferencesBenchmarks.cs (1)
56if (!File.Exists(solutionPath))
FormatterBenchmarks.cs (2)
32if (!File.Exists(csFilePath)) 38var text = File.ReadAllText(csFilePath).Replace("<auto-generated />", "")
IncrementalAnalyzerBenchmarks.cs (1)
38if (!File.Exists(_solutionPath))
IncrementalSourceGeneratorBenchmarks.cs (1)
59if (!File.Exists(_solutionPath))
NavigateToBenchmarks.cs (1)
60if (!File.Exists(_solutionPath))
RenameBenchmarks.cs (2)
30if (!File.Exists(_csFilePath)) 44.AddDocument(documentId, "DocumentName", File.ReadAllText(_csFilePath));
SyntacticChangeRangeBenchmark.cs (2)
35if (!File.Exists(csFilePath)) 38var text = File.ReadAllText(csFilePath);
IIS.FunctionalTests (21)
src\Servers\IIS\IIS\test\Common.FunctionalTests\GlobalVersionTests.cs (3)
72File.Delete(temporaryFile); 73File.Move(requestHandlerPath, temporaryFile); 82File.Delete(temporaryFile);
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\Helpers.cs (5)
217dynamic depsFileContent = JsonConvert.DeserializeObject(File.ReadAllText(path)); 220File.WriteAllText(path, output); 225File.AppendAllText( 234return File.ReadAllText(filename); 267File.WriteAllText(Path.Combine(rootApplicationDirectory.FullName, "web.config"), "<configuration></configuration>");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISFunctionalTestBase.cs (3)
39File.WriteAllText(Path.Combine(appPath, "app_offline.htm"), content); 45() => File.Delete(Path.Combine(appPath, "app_offline.htm")), 83File.Delete(file);
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISSubAppSiteFixture.cs (1)
18deploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.SubApp.Config");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\RequiresIISAttribute.cs (4)
55if (!File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", "w3wp.exe")) && !SkipInVSTSAttribute.RunningInVSTS) 63if (!File.Exists(ancmConfigPath)) 68if (!File.Exists(ancmConfigPath) && !SkipInVSTSAttribute.RunningInVSTS) 95if (File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", module.DllName)) || SkipInVSTSAttribute.RunningInVSTS)
src\Servers\IIS\IIS\test\Common.FunctionalTests\LoggingTests.cs (3)
179File.Delete(firstTempFile); 180File.Delete(secondTempFile); 336using (var stream = File.Open(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
src\Servers\IIS\IIS\test\IIS.Shared.FunctionalTests\ApplicationInitializationTests.cs (2)
57await Helpers.Retry(async () => await File.ReadAllTextAsync(Path.Combine(result.ContentRoot, "Started.txt")), TimeoutExtensions.DefaultTimeoutValue); 101await Helpers.Retry(async () => await File.ReadAllTextAsync(Path.Combine(result.ContentRoot, "Started.txt")), TimeoutExtensions.DefaultTimeoutValue);
IIS.LongTests (26)
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\Helpers.cs (5)
217dynamic depsFileContent = JsonConvert.DeserializeObject(File.ReadAllText(path)); 220File.WriteAllText(path, output); 225File.AppendAllText( 234return File.ReadAllText(filename); 267File.WriteAllText(Path.Combine(rootApplicationDirectory.FullName, "web.config"), "<configuration></configuration>");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISFunctionalTestBase.cs (3)
39File.WriteAllText(Path.Combine(appPath, "app_offline.htm"), content); 45() => File.Delete(Path.Combine(appPath, "app_offline.htm")), 83File.Delete(file);
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISSubAppSiteFixture.cs (1)
18deploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.SubApp.Config");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\RequiresIISAttribute.cs (4)
55if (!File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", "w3wp.exe")) && !SkipInVSTSAttribute.RunningInVSTS) 63if (!File.Exists(ancmConfigPath)) 68if (!File.Exists(ancmConfigPath) && !SkipInVSTSAttribute.RunningInVSTS) 95if (File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", module.DllName)) || SkipInVSTSAttribute.RunningInVSTS)
src\Servers\IIS\IIS\test\Common.LongTests\ShutdownTests.cs (3)
106using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) 124using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) 178File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "Microsoft.AspNetCore.Server.IIS.dll"), "");
src\Servers\IIS\IIS\test\Common.LongTests\StartupTests.cs (10)
213Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe"))); 214Assert.False(File.Exists(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"))); 279File.Copy( 345File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"), ""); 405File.Delete(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.dll")); 446File.Delete(Path.Combine(deploymentResult.ContentRoot, "aspnetcorev2_inprocess.dll")); 744File.WriteAllBytes(applicationDll, File.ReadAllBytes(applicationDll)); 746File.WriteAllBytes(handlerDll, File.ReadAllBytes(handlerDll));
IIS.Microbenchmarks (1)
StartupTimeBenchmark.cs (1)
32ServerConfigTemplateContent = File.ReadAllText("IIS.config"),
IIS.NewHandler.FunctionalTests (26)
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\Helpers.cs (5)
217dynamic depsFileContent = JsonConvert.DeserializeObject(File.ReadAllText(path)); 220File.WriteAllText(path, output); 225File.AppendAllText( 234return File.ReadAllText(filename); 267File.WriteAllText(Path.Combine(rootApplicationDirectory.FullName, "web.config"), "<configuration></configuration>");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISFunctionalTestBase.cs (3)
39File.WriteAllText(Path.Combine(appPath, "app_offline.htm"), content); 45() => File.Delete(Path.Combine(appPath, "app_offline.htm")), 83File.Delete(file);
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISSubAppSiteFixture.cs (1)
18deploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.SubApp.Config");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\RequiresIISAttribute.cs (4)
55if (!File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", "w3wp.exe")) && !SkipInVSTSAttribute.RunningInVSTS) 63if (!File.Exists(ancmConfigPath)) 68if (!File.Exists(ancmConfigPath) && !SkipInVSTSAttribute.RunningInVSTS) 95if (File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", module.DllName)) || SkipInVSTSAttribute.RunningInVSTS)
src\Servers\IIS\IIS\test\Common.LongTests\ShutdownTests.cs (3)
106using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) 124using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) 178File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "Microsoft.AspNetCore.Server.IIS.dll"), "");
src\Servers\IIS\IIS\test\Common.LongTests\StartupTests.cs (10)
213Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe"))); 214Assert.False(File.Exists(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"))); 279File.Copy( 345File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"), ""); 405File.Delete(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.dll")); 446File.Delete(Path.Combine(deploymentResult.ContentRoot, "aspnetcorev2_inprocess.dll")); 744File.WriteAllBytes(applicationDll, File.ReadAllBytes(applicationDll)); 746File.WriteAllBytes(handlerDll, File.ReadAllBytes(handlerDll));
IIS.NewShim.FunctionalTests (26)
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\Helpers.cs (5)
217dynamic depsFileContent = JsonConvert.DeserializeObject(File.ReadAllText(path)); 220File.WriteAllText(path, output); 225File.AppendAllText( 234return File.ReadAllText(filename); 267File.WriteAllText(Path.Combine(rootApplicationDirectory.FullName, "web.config"), "<configuration></configuration>");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISFunctionalTestBase.cs (3)
39File.WriteAllText(Path.Combine(appPath, "app_offline.htm"), content); 45() => File.Delete(Path.Combine(appPath, "app_offline.htm")), 83File.Delete(file);
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISSubAppSiteFixture.cs (1)
18deploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.SubApp.Config");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\RequiresIISAttribute.cs (4)
55if (!File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", "w3wp.exe")) && !SkipInVSTSAttribute.RunningInVSTS) 63if (!File.Exists(ancmConfigPath)) 68if (!File.Exists(ancmConfigPath) && !SkipInVSTSAttribute.RunningInVSTS) 95if (File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", module.DllName)) || SkipInVSTSAttribute.RunningInVSTS)
src\Servers\IIS\IIS\test\Common.LongTests\ShutdownTests.cs (3)
106using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) 124using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) 178File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "Microsoft.AspNetCore.Server.IIS.dll"), "");
src\Servers\IIS\IIS\test\Common.LongTests\StartupTests.cs (10)
213Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe"))); 214Assert.False(File.Exists(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"))); 279File.Copy( 345File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"), ""); 405File.Delete(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.dll")); 446File.Delete(Path.Combine(deploymentResult.ContentRoot, "aspnetcorev2_inprocess.dll")); 744File.WriteAllBytes(applicationDll, File.ReadAllBytes(applicationDll)); 746File.WriteAllBytes(handlerDll, File.ReadAllBytes(handlerDll));
IIS.ShadowCopy.Tests (16)
ShadowCopyTests.cs (3)
131var fileContents = File.ReadAllBytes(dllPath); 132File.WriteAllBytes(dllPath, fileContents); 151File.WriteAllText(Path.Combine(deleteDirPath, "file.dll"), "");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\Helpers.cs (5)
217dynamic depsFileContent = JsonConvert.DeserializeObject(File.ReadAllText(path)); 220File.WriteAllText(path, output); 225File.AppendAllText( 234return File.ReadAllText(filename); 267File.WriteAllText(Path.Combine(rootApplicationDirectory.FullName, "web.config"), "<configuration></configuration>");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISFunctionalTestBase.cs (3)
39File.WriteAllText(Path.Combine(appPath, "app_offline.htm"), content); 45() => File.Delete(Path.Combine(appPath, "app_offline.htm")), 83File.Delete(file);
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISSubAppSiteFixture.cs (1)
18deploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.SubApp.Config");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\RequiresIISAttribute.cs (4)
55if (!File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", "w3wp.exe")) && !SkipInVSTSAttribute.RunningInVSTS) 63if (!File.Exists(ancmConfigPath)) 68if (!File.Exists(ancmConfigPath) && !SkipInVSTSAttribute.RunningInVSTS) 95if (File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", module.DllName)) || SkipInVSTSAttribute.RunningInVSTS)
IIS.Tests (1)
Utilities\SkipIfHostableWebCoreNotAvailibleAttribute.cs (1)
13public bool IsMet { get; } = File.Exists(TestServer.HostableWebCoreLocation);
IISExpress.FunctionalTests (28)
src\Servers\IIS\IIS\test\Common.FunctionalTests\GlobalVersionTests.cs (3)
72File.Delete(temporaryFile); 73File.Move(requestHandlerPath, temporaryFile); 82File.Delete(temporaryFile);
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\Helpers.cs (5)
217dynamic depsFileContent = JsonConvert.DeserializeObject(File.ReadAllText(path)); 220File.WriteAllText(path, output); 225File.AppendAllText( 234return File.ReadAllText(filename); 267File.WriteAllText(Path.Combine(rootApplicationDirectory.FullName, "web.config"), "<configuration></configuration>");
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISFunctionalTestBase.cs (3)
39File.WriteAllText(Path.Combine(appPath, "app_offline.htm"), content); 45() => File.Delete(Path.Combine(appPath, "app_offline.htm")), 83File.Delete(file);
src\Servers\IIS\IIS\test\Common.FunctionalTests\Infrastructure\IISSubAppSiteFixture.cs (1)
18deploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.SubApp.Config");
src\Servers\IIS\IIS\test\Common.FunctionalTests\LoggingTests.cs (3)
179File.Delete(firstTempFile); 180File.Delete(secondTempFile); 336using (var stream = File.Open(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
src\Servers\IIS\IIS\test\Common.LongTests\ShutdownTests.cs (3)
106using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) 124using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) 178File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "Microsoft.AspNetCore.Server.IIS.dll"), "");
src\Servers\IIS\IIS\test\Common.LongTests\StartupTests.cs (10)
213Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe"))); 214Assert.False(File.Exists(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"))); 279File.Copy( 345File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"), ""); 405File.Delete(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.dll")); 446File.Delete(Path.Combine(deploymentResult.ContentRoot, "aspnetcorev2_inprocess.dll")); 744File.WriteAllBytes(applicationDll, File.ReadAllBytes(applicationDll)); 746File.WriteAllBytes(handlerDll, File.ReadAllBytes(handlerDll));
illink (25)
ILLink.Tasks (9)
CreateRuntimeRootDescriptorFile.cs (9)
103if (!File.Exists(namespaceFilePath)) 110if (!File.Exists(mscorlibFilePath)) 117if (!File.Exists(cortypeFilePath)) 124if (!File.Exists(rexcepFilePath)) 133if (!File.Exists(iLLinkTrimXmlFilePath)) 154string[] namespaces = File.ReadAllLines(namespaceFile); 187string[] types = File.ReadAllLines(typeFile); 293string[] corTypes = File.ReadAllLines(corTypeFile); 316string[] excTypes = File.ReadAllLines(excTypeFile);
Infrastructure.Common (1)
CertificateManager.cs (1)
274if (!File.Exists(OSXCustomKeychainFilePath))
InProcessWebSite (5)
Program.cs (1)
27File.WriteAllText(args[1], "");
Startup.cs (4)
188File.WriteAllText(System.IO.Path.Combine(hostingEnv.ContentRootPath, "Started.txt"), ""); 959var fileStream = File.OpenWrite(tempFile); 974File.Delete(tempFile); 1115File.Delete(context.Request.Headers["ANCMRHPath"]);
installer.tasks (9)
GenerateFileVersionProps.cs (2)
136using (var manifestWriter = File.CreateText(PlatformManifestFile)) 167if (File.Exists(filePath))
GenerateRunScript.cs (2)
34if (!File.Exists(TemplatePath)) 40string templateContent = File.ReadAllText(TemplatePath);
GenerateTestSharedFrameworkDepsFile.cs (1)
101using (var depsFileStream = File.Create(Path.Combine(SharedFrameworkDirectory, $"{sharedFxName}.deps.json")))
RegenerateDownloadTable.cs (2)
54string[] readmeLines = File.ReadAllLines(ReadmeFile); 98File.WriteAllLines(
StaticFileRegeneration\RegenerateThirdPartyNotices.cs (2)
129TpnDocument existingTpn = TpnDocument.Parse(File.ReadAllLines(TpnFile)); 184File.WriteAllText(TpnFile, newTpn.ToString());
InteractiveHost.UnitTests (2)
AbstractInteractiveHostTests.cs (1)
50while (dir != null && !File.Exists(Path.Combine(dir, "dotnet.exe")))
InteractiveHostDesktopTests.cs (1)
379File.WriteAllBytes(c.Path, [1, 2, 3]);
Interop.FunctionalTests (3)
H2SpecCommands.cs (2)
267var results = File.ReadAllText(tempFile); 268File.Delete(tempFile);
Http3\Http3TlsTests.cs (1)
445File.WriteAllBytes(path, bytes);
InteropClient (2)
InteropClient.cs (2)
163var pem = File.ReadAllText("Certs/ca.pem"); 859var jobject = JObject.Parse(File.ReadAllText(keyFile));
IOperationGenerator (2)
IOperationClassWriter.cs (2)
107using (_writer = new StreamWriter(File.Open(outFileName, FileMode.Create), Encoding.UTF8)) 161using (_writer = new StreamWriter(File.Open(Path.Combine(_location, "OperationKind.Generated.cs"), FileMode.Create), Encoding.UTF8))
Metrics (6)
Program.cs (2)
113if (!File.Exists(value)) 129if (!File.Exists(value))
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
Metrics.Legacy (6)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Tools\Metrics\Program.cs (2)
113if (!File.Exists(value)) 129if (!File.Exists(value))
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
Microsoft.Agents.AI.ProjectTemplates.Tests (5)
test\ProjectTemplates\Infrastructure\TemplateExecutionTestClassFixtureBase.cs (2)
56File.Copy(WellKnownPaths.TemplateInstallNuGetConfigPath, installNuGetConfigPath); 92File.Copy(WellKnownPaths.TemplateTestNuGetConfigPath, templateNuGetConfigPath);
test\ProjectTemplates\Infrastructure\TemplateExecutionTestCollectionFixture.cs (1)
36File.Copy(filePath, destFilePath);
test\ProjectTemplates\Infrastructure\WellKnownPaths.cs (2)
53if (Directory.Exists(gitPath) || File.Exists(gitPath)) 74if (!File.Exists(dotNetExePath))
Microsoft.Analyzers.Extra.Tests (1)
Resources\FileVisibleToAnalyzer.cs (1)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Microsoft.Analyzers.Local.Tests (1)
Resources\FileVisibleToAnalyzer.cs (1)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Microsoft.Arcade.Common (10)
CommandFactory.cs (2)
64if (File.Exists(executable + ".exe")) 76if (File.Exists(candidate))
FileSystem.cs (5)
17public bool FileExists(string path) => File.Exists(path); 19public void DeleteFile(string path) => File.Delete(path); 39File.WriteAllText(path, content); 42public virtual void CopyFile(string sourceFileName, string destFileName, bool overwrite = false) => File.Copy(sourceFileName, destFileName, overwrite); 46public FileAttributes GetAttributes(string path) => File.GetAttributes(path);
NupkgInfoFactory.cs (1)
31using Stream stream = File.OpenRead(path);
ZipArchiveManager.cs (2)
29bool archiveExists = File.Exists(archivePath); 32using FileStream fs = File.OpenWrite(archivePath);
Microsoft.AspNetCore.Analyzer.Testing (2)
DiagnosticVerifier.cs (2)
195if (File.Exists(dll)) 202if (File.Exists(dll))
Microsoft.AspNetCore.App.UnitTests (15)
AssertEx.cs (2)
20if (!File.Exists(path)) 28if (File.Exists(path))
PackageTests.cs (2)
96using var fileStream = File.OpenRead(assembly); 126using var fileStream = File.OpenRead(assembly);
SharedFxTests.cs (5)
93var runtimeConfig = JObject.Parse(File.ReadAllText(runtimeConfigFilePath)); 113var depsFile = JObject.Parse(File.ReadAllText(depsFilePath)); 187using var fileStream = File.OpenRead(path); 234using var fileStream = File.OpenRead(path); 252var lines = File.ReadAllLines(versionFile);
TargetingPackTests.cs (6)
84using var fileStream = File.OpenRead(path); 118using var fileStream = File.OpenRead(path); 139var packageOverrideFileLines = File.ReadAllLines(packageOverridePath); 217using var fileStream = File.OpenRead(path); 256_output.WriteLine(File.ReadAllText(platformManifestPath)); 262var manifestFileLines = File.ReadAllLines(platformManifestPath);
Microsoft.AspNetCore.Authentication.JwtBearer.Tools.Tests (26)
src\Tools\Shared\TestHelpers\TemporaryDirectory.cs (2)
59using (var stream = File.OpenRead(Path.Combine("TestContent", $"{name}.txt"))) 98File.WriteAllText(Path.Combine(Root, filename), contents);
UserJwtsTestFixture.cs (4)
73File.WriteAllText( 77File.WriteAllText(Path.Combine(projectPath.FullName, "Properties", "launchSettings.json"), 80File.WriteAllText( 84File.WriteAllText(
UserJwtsTests.cs (20)
67Assert.Contains("dotnet-user-jwts", File.ReadAllText(appsettings)); 112var appSettings = JsonSerializer.Deserialize<JsonObject>(File.ReadAllText(appsettings)); 115appSettings = JsonSerializer.Deserialize<JsonObject>(File.ReadAllText(appsettings)); 129var appSettings = JsonSerializer.Deserialize<JsonObject>(File.ReadAllText(appsettings)); 132appSettings = JsonSerializer.Deserialize<JsonObject>(File.ReadAllText(appsettings)); 206var appsettingsContent = File.ReadAllText(appsettings); 224var appsettingsContent = File.ReadAllText(appsettings); 242var appsettingsContent = File.ReadAllText(appsettings); 260var appsettingsContent = File.ReadAllText(appsettings); 285await File.WriteAllTextAsync(secretsFilePath, 299using var openStream = File.OpenRead(secretsFilePath); 493File.Delete(launchSettingsPath); 507await File.WriteAllTextAsync(secretsFilePath, 518using var openStream = File.OpenRead(secretsFilePath); 534await File.WriteAllTextAsync(secretsFilePath, 546using var openStream = File.OpenRead(secretsFilePath); 585using var openStream = File.OpenRead(secretsFilePath); 607using var openStream = File.OpenRead(secretsFilePath); 629using var openStream = File.OpenRead(secretsFilePath); 863Assert.Equal(UnixFileMode.UserRead | UnixFileMode.UserWrite, File.GetUnixFileMode(app.UserJwtsFilePath));
Microsoft.AspNetCore.Authentication.Test (4)
WsFederation\WsFederationTest.cs (2)
257kvps.Add(new KeyValuePair<string, string>("wresult", File.ReadAllText(tokenFile))); 459var metadata = File.ReadAllText(@"WsFederation/federationmetadata.xml");
WsFederation\WsFederationTest_Handler.cs (2)
248kvps.Add(new KeyValuePair<string, string>("wresult", File.ReadAllText(tokenFile))); 448var metadata = File.ReadAllText(@"WsFederation/federationmetadata.xml");
Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests (1)
TransformTest.cs (1)
84var transformFile = File.ReadAllText("applicationHost.xdt");
Microsoft.AspNetCore.Components.Analyzers.Tests (2)
AnalyzerTestBase.cs (2)
22if (!File.Exists(filePath)) 27var fileContent = File.ReadAllText(filePath);
Microsoft.AspNetCore.Components.SdkAnalyzers.Tests (2)
AnalyzerTestBase.cs (2)
22if (!File.Exists(filePath)) 27var fileContent = File.ReadAllText(filePath);
Microsoft.AspNetCore.Components.WebAssembly (2)
Hosting\WebAssemblyHostBuilder.cs (2)
202if (File.Exists(configFile)) 204var appSettingsJson = File.ReadAllBytes(configFile);
Microsoft.AspNetCore.Components.WebAssembly.Server (2)
DebugProxyLauncher.cs (1)
130if (!File.Exists(debugProxyPath))
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
Microsoft.AspNetCore.Components.WebView (2)
WebViewManager.cs (2)
282if (File.Exists(manifestPath)) 284using var manifestStream = File.OpenRead(manifestPath);
Microsoft.AspNetCore.DataProtection (10)
Internal\ContainerUtils.cs (4)
34if (!File.Exists(mountsFile)) 39var lines = File.ReadAllLines(mountsFile); 99if (!File.Exists(procFile)) 104var lines = File.ReadAllLines(procFile);
Repositories\FileSystemXmlRepository.cs (6)
111using (var fileStream = File.OpenRead(fullPath)) 147File.Move(tempTempFilename, tempFilename); 152using (var tempFileStream = File.OpenWrite(tempFilename)) 164File.Move(tempFilename, finalFilename); 170File.Copy(tempFilename, finalFilename); 175File.Delete(tempFilename); // won't throw if the file doesn't exist
Microsoft.AspNetCore.DataProtection.Extensions.Tests (6)
DataProtectionProviderTests.cs (6)
41string fileText = File.ReadAllText(allFiles[0].FullName); 76var fileText = File.ReadAllText(file.FullName); 110string fileText = File.ReadAllText(allFiles[0].FullName); 156string fileText = File.ReadAllText(allFiles[0].FullName); 236string fileText = File.ReadAllText(allFiles[0].FullName); 307string fileText = File.ReadAllText(allFiles[0].FullName);
Microsoft.AspNetCore.DataProtection.Tests (11)
Repositories\FileSystemXmlRepositoryTests.cs (11)
82var parsedElement = XElement.Parse(File.ReadAllText(fileInfo.FullName)); 116var parsedElement = XElement.Parse(File.ReadAllText(fileInfo.FullName)); 209Assert.True(File.Exists(filePath1)); 210Assert.True(File.Exists(filePath2)); 211Assert.True(File.Exists(filePath3)); 240Assert.True(File.Exists(filePath1)); // Deletion not attempted after failure 241Assert.True(File.Exists(filePath2)); // Deletion fails because of lock 242Assert.False(File.Exists(filePath3)); // Deleted before error 256Assert.True(File.Exists(filePath)); 265File.Delete(filePath); 273Assert.False(File.Exists(filePath));
Microsoft.AspNetCore.DeveloperCertificates.XPlat (21)
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
Microsoft.AspNetCore.DeveloperCertificates.XPlat.Tests (12)
CertificateManagerTests.cs (12)
50Assert.True(File.Exists(CertificateName)); 52var exportedCertificate = new X509Certificate2(File.ReadAllBytes(CertificateName)); 149Assert.True(File.Exists(CertificateName)); 151var exportedCertificate = new X509Certificate2(File.ReadAllBytes(CertificateName), certificatePassword); 183Assert.True(File.Exists(CertificateName)); 216Assert.True(File.Exists(CertificateName)); 314File.WriteAllBytes(CertificateName, wrongSubjectCertificate.Export(X509ContentType.Pfx, certificatePassword)); 345Assert.True(File.Exists(CertificateName)); 538Assert.True(File.Exists(CertificateName)); 539Assert.Equal(UnixFileMode.UserRead | UnixFileMode.UserWrite, File.GetUnixFileMode(CertificateName)); 541Assert.True(File.Exists(KeyName)); 542Assert.Equal(UnixFileMode.UserRead | UnixFileMode.UserWrite, File.GetUnixFileMode(KeyName));
Microsoft.AspNetCore.Diagnostics (3)
src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (3)
110if (File.Exists(stackFrame.File)) 112lines = File.ReadLines(stackFrame.File); 124lines = File.ReadLines(fileInfo.PhysicalPath);
Microsoft.AspNetCore.FunctionalTests (6)
WebApplicationFunctionalTests.cs (4)
21await File.WriteAllTextAsync(Path.Combine(contentRootPath, "appsettings.json"), @" 64await File.WriteAllTextAsync(Path.Combine(contentRootPath, "appsettings.Development.json"), @" 107await File.WriteAllTextAsync(Path.Combine(contentRootPath, "appsettings.json"), @" 143await File.WriteAllTextAsync(Path.Combine(contentRootPath, "appsettings.json"), @"
WebHostFunctionalTests.cs (2)
115File.WriteAllText("appsettings.json", @" 147File.Delete("appsettings.json");
Microsoft.AspNetCore.Grpc.Swagger.Tests (1)
XmlComments\XmlCommentsDocumentFilterTests.cs (1)
67using (var xmlComments = File.OpenText($"{typeof(GreeterService).Assembly.GetName().Name}.xml"))
Microsoft.AspNetCore.Hosting (5)
src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (3)
110if (File.Exists(stackFrame.File)) 112lines = File.ReadLines(stackFrame.File); 124lines = File.ReadLines(fileInfo.PhysicalPath);
StaticWebAssets\StaticWebAssetsLoader.cs (2)
51if (candidate != null && File.Exists(candidate)) 53return File.OpenRead(candidate);
Microsoft.AspNetCore.Http.Abstractions.Tests (2)
EndpointFilterInvocationContextOfTTests.cs (2)
91var compiledTemplate = generator.CompileTemplate(File.ReadAllText(templatePath)); 94var currentContent = File.ReadAllText(currentContentPath);
Microsoft.AspNetCore.Http.Microbenchmarks (4)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (4)
369await File.WriteAllTextAsync(baselineFilePath, newSource); 373var baseline = await File.ReadAllTextAsync(baselineFilePath); 423if (File.Exists(dll)) 431if (File.Exists(dll))
Microsoft.AspNetCore.Http.Results.Tests (8)
ResultsCacheTests.cs (2)
17var compiledTemplate = generator.CompileTemplate(File.ReadAllText(templatePath)); 20var currentContent = File.ReadAllText(currentContentPath);
ResultsOfTTests.cs (6)
35var currentResultsOfTGenerated = File.ReadAllText(resultsOfTGeneratedPath); 36var currentTestsGenerated = File.ReadAllText(testsGeneratedPath); 40var testResultsOfTGenerated = File.ReadAllText(testResultsOfTGeneratedPath); 41var testTestsGenerated = File.ReadAllText(testTestsGeneratedPath); 48File.Delete(testResultsOfTGeneratedPath); 49File.Delete(testTestsGeneratedPath);
Microsoft.AspNetCore.HttpLogging (1)
FileLoggerProcessor.cs (1)
273return File.AppendText(fileName);
Microsoft.AspNetCore.HttpLogging.Tests (30)
FileLoggerProcessorTests.cs (30)
51Assert.True(File.Exists(filePath)); 53Assert.Equal(_messageOne + Environment.NewLine, File.ReadAllText(filePath)); 98Assert.True(File.Exists(filePathToday)); 99Assert.Equal(_messageOne + Environment.NewLine, File.ReadAllText(filePathToday)); 100Assert.True(File.Exists(filePathTomorrow)); 101Assert.Equal(_messageTwo + Environment.NewLine, File.ReadAllText(filePathTomorrow)); 137Assert.True(File.Exists(filePath1)); 138Assert.True(File.Exists(filePath2)); 140Assert.Equal(_messageOne + Environment.NewLine, File.ReadAllText(filePath1)); 141Assert.Equal(_messageTwo + Environment.NewLine, File.ReadAllText(filePath2)); 154File.WriteAllText(Path.Combine(path, "randomFile.txt"), "Text"); 400Assert.True(File.Exists(filePath1)); 401Assert.True(File.Exists(filePath2)); 402Assert.True(File.Exists(filePath3)); 404Assert.Equal(_messageOne + Environment.NewLine, File.ReadAllText(filePath1)); 405Assert.Equal(_messageTwo + Environment.NewLine, File.ReadAllText(filePath2)); 406Assert.Equal(_messageThree + Environment.NewLine, File.ReadAllText(filePath3)); 466Assert.False(File.Exists(filePath1)); 467Assert.False(File.Exists(filePath2)); 468Assert.True(File.Exists(filePath3)); 469Assert.True(File.Exists(filePath4)); 471Assert.Equal(_messageThree + Environment.NewLine, File.ReadAllText(filePath3)); 472Assert.Equal(_messageFour + Environment.NewLine, File.ReadAllText(filePath4)); 536Assert.True(File.Exists(filePath1)); 537Assert.True(File.Exists(filePath2)); 539Assert.Equal(_messageOne + Environment.NewLine, File.ReadAllText(filePath1)); 540Assert.Equal(_messageTwo + Environment.NewLine, File.ReadAllText(filePath2)); 550while (!File.Exists(filePath)) 558if (File.ReadAllText(filePath).Length >= length) 581while (File.Exists(filePath))
Microsoft.AspNetCore.Identity.Test (2)
IdentityUIScriptsTest.cs (2)
86var fallbackSrcContent = File.ReadAllText( 129using (var stream = File.OpenRead(cshtmlFile))
Microsoft.AspNetCore.InternalTesting (10)
AssemblyTestLog.cs (4)
142if (File.Exists(testOutputFile)) 150if (!File.Exists(testOutputFile)) 280if (File.Exists(fileName)) 282File.Delete(fileName);
HelixHelper.cs (1)
22File.Copy(filePath, uploadPath, overwrite: true);
TestFileOutputContext.cs (1)
67while (File.Exists(path))
xunit\DockerOnlyAttribute.cs (2)
27if (!File.Exists(procFile)) 32var lines = File.ReadAllLines(procFile);
xunit\SkipOnAlpineAttribute.cs (2)
30RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/etc/os-release") && 31File.ReadAllLines("/etc/os-release").Any(line =>
Microsoft.AspNetCore.InternalTesting.Tests (14)
AssemblyTestLogTests.cs (14)
67Assert.True(File.Exists(globalLogPath), $"Expected global log file {globalLogPath} to exist."); 68Assert.True(File.Exists(testLog), $"Expected test log file {testLog} to exist."); 160Assert.True(File.Exists(globalLogPath), $"Expected global log file {globalLogPath} to exist"); 161Assert.True(File.Exists(testLog), $"Expected test log file {testLog} to exist"); 163var globalLogContent = MakeConsistent(File.ReadAllText(globalLogPath)); 164var testLogContent = MakeConsistent(File.ReadAllText(testLog)); 215Assert.True(File.Exists(globalLogPath), $"Expected global log file {globalLogPath} to exist."); 216Assert.True(File.Exists(testLog), $"Expected test log file {testLog} to exist."); 221Assert.True(!File.Exists(globalLogPath), $"Expected no global log file {globalLogPath} to exist."); 222Assert.True(!File.Exists(testLog), $"Expected no test log file {testLog} to exist."); 266Assert.True(File.Exists(globalLogPath), $"Expected global log file {globalLogPath} to exist."); 267Assert.True(File.Exists(testLog), $"Expected test log file {testLog} to exist."); 343Assert.True(File.Exists(Path.Combine( 353Assert.True(File.Exists(Path.Combine(
Microsoft.AspNetCore.Mvc.Core (1)
ApplicationParts\RelatedAssemblyAttribute.cs (1)
44return GetRelatedAssemblies(assembly, throwOnError, File.Exists, new AssemblyLoadContextWrapper(loadContext));
Microsoft.AspNetCore.Mvc.FunctionalTests (2)
Infrastructure\ResourceFile.cs (1)
255using (var stream = File.Open(fullPath, FileMode.Create, FileAccess.Write))
WebApplicationFactorySlnxTests.cs (1)
38File.WriteAllText(slnxFile, """
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (1)
RazorReferenceManager.cs (1)
79using (var stream = File.OpenRead(path))
Microsoft.AspNetCore.Mvc.Testing (3)
WebApplicationFactory.cs (3)
376var fromFile = File.Exists("MvcTestingAppManifest.json"); 391var data = JsonSerializer.Deserialize(File.ReadAllBytes(file), CustomJsonSerializerContext.Default.IDictionaryStringString)!; 425if (File.Exists(contentRootMarker))
Microsoft.AspNetCore.Mvc.Testing.Tasks (1)
GenerateMvcTestManifestTask.cs (1)
34using var fileStream = File.Create(ManifestPath);
Microsoft.AspNetCore.OpenApi.Build.Tests (6)
GenerateAdditionalXmlFilesForOpenApiTests.cs (5)
60File.WriteAllText(classLibProjectPath, classLibProjectContent); 72File.WriteAllText(classLibSourcePath, classLibSourceContent); 80File.Copy(sourceTargetsPath, targetTargetsPath); 98File.WriteAllText(projectPath, projectContent); 111File.WriteAllText(sourcePath, sourceContent);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
Microsoft.AspNetCore.ResponseCompression.Tests (1)
ResponseCompressionBodyTest.cs (1)
73Assert.Equal(File.ReadAllBytes(path), memoryStream.ToArray());
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (4)
ResponseCachingTests.cs (2)
26using var file = File.Create(_absoluteFilePath); 37File.Delete(_absoluteFilePath);
ResponseSendFileTests.cs (2)
309var emptyFile = File.Create(emptyFilePath, 1024); 329File.Delete(emptyFilePath);
Microsoft.AspNetCore.Server.IIS (3)
src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (3)
110if (File.Exists(stackFrame.File)) 112lines = File.ReadLines(stackFrame.File); 124lines = File.ReadLines(fileInfo.PhysicalPath);
Microsoft.AspNetCore.Server.IntegrationTesting (10)
Deployers\ApplicationDeployer.cs (1)
106if (!File.Exists(executableName))
Deployers\NginxDeployer.cs (5)
155File.WriteAllText(_configFile, DeploymentParameters.ServerConfigTemplateContent); 180if (!File.Exists(pidFile)) 186var pid = File.ReadAllText(pidFile); 197if (File.Exists(_configFile)) 219File.Delete(_configFile);
Deployers\RemoteWindowsDeployer\RemoteWindowsDeployer.cs (2)
186using (var fileStream = File.Open(webConfigFilePath, FileMode.Open)) 325var destinationStream = File.Create(physicalFilePath);
Deployers\SelfHostDeployer.cs (1)
137Logger.LogInformation($"{File.Exists(executableName)}");
xunit\IISExpressAncmSchema.cs (1)
25if (!File.Exists(ancmConfigPath))
Microsoft.AspNetCore.Server.IntegrationTesting.IIS (16)
IISDeployer.cs (7)
83DeploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.config"); 186if (File.Exists(file)) 188var lines = File.ReadAllLines(file); 205if (File.Exists(_debugLogFile)) 207File.Delete(_debugLogFile); 311var config = XDocument.Parse(DeploymentParameters.ServerConfigTemplateContent ?? File.ReadAllText("IIS.config")); 515File.WriteAllText(tmpFile, DumpServerManagerConfig());
IISDeployerBase.cs (3)
94var basePath = File.Exists(Path.Combine(AppContext.BaseDirectory, "x64", "aspnetcorev2.dll")) ? "" : @"ANCM\"; 97if (!File.Exists(Environment.ExpandEnvironmentVariables(ancmFile))) 100if (!File.Exists(Environment.ExpandEnvironmentVariables(ancmFile)))
IISExpressDeployer.cs (6)
299if (!DeploymentParameters.PublishApplicationBeforeDeployment && !File.Exists(webConfigPath)) 311File.WriteAllText(DeploymentParameters.ServerConfigLocation, serverConfig); 361if (!File.Exists(executableName)) 386if (!File.Exists(iisExpressPath)) 413&& File.Exists(DeploymentParameters.ServerConfigLocation)) 419File.Delete(DeploymentParameters.ServerConfigLocation);
Microsoft.AspNetCore.Server.Kestrel.Core (23)
Internal\Certificates\CertificateConfigLoader.cs (1)
137var keyText = File.ReadAllText(keyPath);
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
TlsConfigurationLoader.cs (1)
157File.Exists(certificatePath))
Microsoft.AspNetCore.Server.Kestrel.Tests (47)
GeneratedCodeTests.cs (15)
38var currentHttpHeadersGenerated = File.ReadAllText(httpHeadersGeneratedPath); 39var currentHttpProtocolGenerated = File.ReadAllText(httpProtocolGeneratedPath); 40var currentHttpUtilitiesGenerated = File.ReadAllText(httpUtilitiesGeneratedPath); 41var currentTransportConnectionBaseGenerated = File.ReadAllText(transportMultiplexedConnectionGeneratedPath); 42var currentTransportConnectionGenerated = File.ReadAllText(transportConnectionGeneratedPath); 50var testHttpHeadersGenerated = File.ReadAllText(testHttpHeadersGeneratedPath); 51var testHttpProtocolGenerated = File.ReadAllText(testHttpProtocolGeneratedPath); 52var testHttpUtilitiesGenerated = File.ReadAllText(testHttpUtilitiesGeneratedPath); 53var testTransportMultiplxedConnectionGenerated = File.ReadAllText(testTransportMultiplexedConnectionGeneratedPath); 54var testTransportConnectionGenerated = File.ReadAllText(testTransportConnectionGeneratedPath); 64File.Delete(testHttpHeadersGeneratedPath); 65File.Delete(testHttpProtocolGeneratedPath); 66File.Delete(testHttpUtilitiesGeneratedPath); 67File.Delete(testTransportMultiplexedConnectionGeneratedPath); 68File.Delete(testTransportConnectionGeneratedPath);
KestrelConfigurationLoaderTests.cs (32)
280File.WriteAllBytes(path, bytes); 303if (File.Exists(GetCertificatePath())) 305File.Delete(GetCertificatePath()); 321File.WriteAllBytes(devCertPath, devCertBytes); 385if (File.Exists(GetCertificatePath())) 387File.Delete(GetCertificatePath()); 447File.WriteAllBytes(path, bytes); 477if (File.Exists(GetCertificatePath())) 479File.Delete(GetCertificatePath()); 494File.WriteAllBytes(path, bytes); 526if (File.Exists(GetCertificatePath())) 528File.Delete(GetCertificatePath()); 543File.WriteAllBytes(path, bytes); 579if (File.Exists(GetCertificatePath())) 581File.Delete(GetCertificatePath()); 919File.WriteAllText(certificatePath, certificate.ExportCertificatePem()); 924File.WriteAllBytes(certificatePath, certificate.Export(X509ContentType.Cert)); 927File.WriteAllText(keyPath, keyPem); 985File.WriteAllBytes(path, bytes); 1000if (File.Exists(GetCertificatePath())) 1002File.Delete(GetCertificatePath()); 1013if (File.Exists(GetCertificatePath())) 1015File.Delete(GetCertificatePath()); 1031if (File.Exists(GetCertificatePath())) 1033File.Delete(GetCertificatePath()); 1141File.WriteAllBytes(certificatePath, oldCertificateBytes); 1171File.WriteAllBytes(certificatePath, newCertificateBytes); 1195if (File.Exists(certificatePath)) 1198File.Delete(certificatePath); 1226var fileLink = File.CreateSymbolicLink(Path.Combine(tempDir, "tls.key"), "./link/tls.key"); 1235File.WriteAllBytes(oldCertPath, oldCertificateBytes); 1240File.WriteAllBytes(newCertPath, newCertificateBytes);
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (2)
SkipOnMarinerAttribute.cs (2)
25RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/etc/os-release") && 26File.ReadAllLines("/etc/os-release").Any(line =>
Microsoft.AspNetCore.Shared.Tests (23)
DotNetMuxerTests.cs (1)
19Assert.True(File.Exists(muxerPath), "The file did not exist");
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests (1)
Docker.cs (1)
66if (File.Exists(candidate))
Microsoft.AspNetCore.SpaProxy (2)
SpaHostingStartup.cs (1)
21if (File.Exists(spaProxyConfigFile))
SpaProxyLaunchManager.cs (1)
300File.WriteAllText(scriptPath, stopScript.ReplaceLineEndings());
Microsoft.AspNetCore.StaticAssets (2)
StaticAssetsEndpointRouteBuilderExtensions.cs (1)
65if (!File.Exists(manifestPath))
StaticAssetsManifest.cs (1)
28using var stream = File.OpenRead(manifestPath);
Microsoft.AspNetCore.StaticAssets.Tests (8)
StaticAssetsIntegrationTests.cs (8)
327File.WriteAllText(filePath, "Hello, World!"); 382File.WriteAllText(Path.Combine(webRoot, "sample.txt"), "Hello, World! Modified"); 435File.WriteAllText(Path.Combine(webRoot, "sample.txt"), "Hello, World! Modified"); 459using (var fileStream = File.OpenRead(filePath)) 493File.WriteAllText(filePath, resource.Content); 537using var stream = File.Create(manifestPath); 544using var fileStream = File.Create(filePath); 554using var stream = File.OpenRead(compressedFilePath);
Microsoft.AspNetCore.StaticFiles.FunctionalTests (1)
StaticFileMiddlewareTests.cs (1)
108var last = File.GetLastWriteTimeUtc(Path.Combine(AppContext.BaseDirectory, "TestDocument.txt"));
Microsoft.AspNetCore.StaticFiles.Tests (2)
StaticFileMiddlewareTests.cs (2)
54Assert.True(File.Exists(badLink), "Should have created a symlink"); 79File.Delete(badLink);
Microsoft.AspNetCore.TestHost.Tests (9)
UseSolutionRelativeContentRootTests.cs (9)
27File.WriteAllText(solutionFile, "Microsoft Visual Studio Solution File, Format Version 12.00"); 45File.WriteAllText(solutionFile, """ 74File.WriteAllText(slnFile, "Microsoft Visual Studio Solution File, Format Version 12.00"); 75File.WriteAllText(slnxFile, """ 103File.WriteAllText(slnFile, "Microsoft Visual Studio Solution File, Format Version 12.00"); 104File.WriteAllText(slnxFile, """ 129File.WriteAllText(slnFile, "Microsoft Visual Studio Solution File, Format Version 12.00"); 130File.WriteAllText(slnxFile, """ 171File.WriteAllText(solutionFile, """
Microsoft.AspNetCore.WebSockets.ConformanceTests (8)
Autobahn\AutobahnSpec.cs (1)
47File.WriteAllText(file, GetJson().ToString(Formatting.Indented));
Autobahn\AutobahnTester.cs (4)
55if (File.Exists(specFile)) 57File.Delete(specFile); 65using (var reader = new StreamReader(File.OpenRead(outputFile))) 141ServerConfigTemplateContent = (server == ServerType.IISExpress) ? File.ReadAllText(configPath) : null,
Autobahn\Executable.cs (1)
25if (File.Exists(candidate))
Autobahn\Wstest.cs (1)
23return (location == null || !File.Exists(location)) ? null : new Wstest(location);
AutobahnTests.cs (1)
87return File.Exists(iisExpressExe) && FileVersionInfo.GetVersionInfo(iisExpressExe).FileMajorPart >= 10;
Microsoft.AspNetCore.WebUtilities (2)
FileBufferingReadStream.cs (1)
249File.Move(tempTempFileName, _tempFileName);
FileBufferingWriteStream.cs (1)
276File.Move(tempTempFileName, tempFileName);
Microsoft.AspNetCore.WebUtilities.Tests (24)
FileBufferingReadStreamTests.cs (23)
128Assert.True(File.Exists(tempFileName)); 136Assert.True(File.Exists(tempFileName)); 142Assert.False(File.Exists(tempFileName)); 163Assert.False(File.Exists(stream.TempFileName)); 189Assert.True(File.Exists(tempFileName)); 197Assert.False(File.Exists(tempFileName)); 290Assert.True(File.Exists(tempFileName)); 298Assert.True(File.Exists(tempFileName)); 304Assert.False(File.Exists(tempFileName)); 321Assert.True(File.Exists(tempFileName)); 345Assert.False(File.Exists(tempFileName)); 366Assert.False(File.Exists(stream.TempFileName)); 392Assert.True(File.Exists(tempFileName)); 400Assert.False(File.Exists(tempFileName)); 419Assert.False(File.Exists(stream.TempFileName), "tempFile should not be created as yet"); 422Assert.True(File.Exists(stream.TempFileName), "tempFile should be created"); 429Assert.False(File.Exists(tempFileName)); 448Assert.False(File.Exists(stream.TempFileName), "tempFile should not be created as yet"); 451Assert.True(File.Exists(stream.TempFileName), "tempFile should be created"); 458Assert.False(File.Exists(tempFileName)); 623Assert.True(File.Exists(tempFileName)); 624Assert.Equal(UnixFileMode.UserRead | UnixFileMode.UserWrite, File.GetUnixFileMode(tempFileName)); 627Assert.False(File.Exists(tempFileName));
FileBufferingWriteStreamTests.cs (1)
383Assert.Equal(UnixFileMode.UserRead | UnixFileMode.UserWrite, File.GetUnixFileMode(bufferingStream.FileStream.SafeFileHandle));
Microsoft.Build.Tasks.CodeAnalysis (21)
src\Compilers\Core\MSBuildTask\CopyRefAssembly.cs (6)
36if (!File.Exists(SourcePath)) 42if (File.Exists(DestinationPath)) 70Log.LogMessageFromResources(MessageImportance.Low, "CopyRefAssembly_Changed", SourcePath, File.GetLastWriteTimeUtc(SourcePath).ToString("O"), source, DestinationPath, File.GetLastWriteTimeUtc(DestinationPath).ToString("O"), destination); 87File.Copy(SourcePath, DestinationPath, overwrite: true); 101using (FileStream source = File.OpenRead(path))
src\Compilers\Core\MSBuildTask\Csc.cs (1)
212if (File.Exists(rspFile))
src\Compilers\Core\MSBuildTask\GenerateMSBuildEditorConfig.cs (3)
117if (File.Exists(targetFileName)) 119string existingContents = File.ReadAllText(targetFileName); 126File.WriteAllText(targetFileName, ConfigFileContents, encoding);
src\Compilers\Core\MSBuildTask\ManagedCompiler.cs (1)
1220if (!File.Exists(reference.ItemSpec))
src\Compilers\Core\MSBuildTask\ManagedToolTask.cs (1)
73_useAppHost = useAppHost = File.Exists(Path.Combine(GetToolDirectory(), AppHostToolName));
src\Compilers\Core\MSBuildTask\Utilities.cs (1)
126File.Delete(path);
src\Compilers\Core\MSBuildTask\Vbc.cs (2)
329File.Move(actualPdbInfo.FullName, desiredLocation); 396if (File.Exists(rspFile))
src\Compilers\Shared\BuildServerConnection.cs (4)
439if (!File.Exists(processFilePath)) 529if (!File.Exists(serverInfo.processFilePath)) 821if (!File.Exists(FilePath)) 851File.Delete(FilePath);
src\Compilers\Shared\RuntimeHostInfo.cs (2)
43var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 91if (File.Exists(filePath))
Microsoft.Build.Tasks.CodeAnalysis.Sdk (22)
src\Compilers\Core\MSBuildTask\CopyRefAssembly.cs (6)
36if (!File.Exists(SourcePath)) 42if (File.Exists(DestinationPath)) 70Log.LogMessageFromResources(MessageImportance.Low, "CopyRefAssembly_Changed", SourcePath, File.GetLastWriteTimeUtc(SourcePath).ToString("O"), source, DestinationPath, File.GetLastWriteTimeUtc(DestinationPath).ToString("O"), destination); 87File.Copy(SourcePath, DestinationPath, overwrite: true); 101using (FileStream source = File.OpenRead(path))
src\Compilers\Core\MSBuildTask\Csc.cs (1)
212if (File.Exists(rspFile))
src\Compilers\Core\MSBuildTask\GenerateMSBuildEditorConfig.cs (3)
117if (File.Exists(targetFileName)) 119string existingContents = File.ReadAllText(targetFileName); 126File.WriteAllText(targetFileName, ConfigFileContents, encoding);
src\Compilers\Core\MSBuildTask\ManagedCompiler.cs (1)
1220if (!File.Exists(reference.ItemSpec))
src\Compilers\Core\MSBuildTask\ManagedToolTask.cs (1)
73_useAppHost = useAppHost = File.Exists(Path.Combine(GetToolDirectory(), AppHostToolName));
src\Compilers\Core\MSBuildTask\Utilities.cs (1)
126File.Delete(path);
src\Compilers\Core\MSBuildTask\Vbc.cs (2)
329File.Move(actualPdbInfo.FullName, desiredLocation); 396if (File.Exists(rspFile))
src\Compilers\Shared\BuildServerConnection.cs (4)
439if (!File.Exists(processFilePath)) 529if (!File.Exists(serverInfo.processFilePath)) 821if (!File.Exists(FilePath)) 851File.Delete(FilePath);
src\Compilers\Shared\NativeMethods.cs (1)
103extension(File)
src\Compilers\Shared\RuntimeHostInfo.cs (2)
43var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 91if (File.Exists(filePath))
Microsoft.Build.Tasks.CodeAnalysis.Sdk.UnitTests (4)
src\Compilers\Core\MSBuildTaskTests\TestUtilities\IntegrationTestBase.cs (4)
141File.Move(originalAppHost, backupAppHost); 172File.Move(backupAppHost, originalAppHost); 212File.Move(originalAppHost, backupAppHost); 247File.Move(backupAppHost, originalAppHost);
Microsoft.Build.Tasks.CodeAnalysis.UnitTests (34)
CopyRefAssemblyTests.cs (10)
47File.WriteAllText(file.Path, ""); 65File.WriteAllText(file.Path, "test"); 77Assert.Equal("test", File.ReadAllText(dest)); 85File.WriteAllText(source.Path, "test"); 87File.WriteAllText(dest.Path, "dest"); 104Assert.Equal("test", File.ReadAllText(dest.Path)); 112File.WriteAllBytes(source.Path, TestResources.General.MVID1); 113var sourceTimestamp = File.GetLastWriteTimeUtc(source.Path).ToString("O"); 116File.WriteAllBytes(dest.Path, TestResources.General.MVID2); 117var destTimestamp = File.GetLastWriteTimeUtc(dest.Path).ToString("O");
DotNetSdkTests.cs (6)
113File.ReadAllText(sourceLinkJsonPath)); 152File.ReadAllText(sourceLinkJsonPath)); 190File.ReadAllText(sourceLinkJsonPath)); 228File.ReadAllText(sourceLinkJsonPath)); 268File.ReadAllText(sourceLinkJsonPath)); 308File.ReadAllText(sourceLinkJsonPath));
GenerateMSBuildEditorConfigTests.cs (2)
376Assert.True(File.Exists(fileName)); 378Assert.Equal(expectedContents, File.ReadAllText(fileName));
RuntimeHostInfoTests.cs (2)
30: File.ResolveLinkTarget(path, returnFinalTarget: true); 84File.CreateSymbolicLink(path: symlinkPath, pathToTarget: globalDotNetExe.Path);
SdkIntegrationTests.cs (1)
48Assert.True(File.Exists(targets));
TestUtilities\DotNetSdkTestBase.cs (9)
73=> dotnetDir != null && File.Exists(Path.Combine(dotnetDir, DotNetExeName)) && Directory.Exists(GetSdkPath(dotnetDir, DotNetSdkVersion)); 99File.WriteAllText(filePath, 117File.WriteAllText(filePath, 177Assert.True(File.Exists(csharpCoreTargets)); 178Assert.True(File.Exists(visualBasicCoreTargets)); 196Assert.True(File.Exists(Path.Combine(ObjDir.Path, "project.assets.json"))); 197Assert.True(File.Exists(Path.Combine(ObjDir.Path, ProjectFileName + ".nuget.g.props"))); 198Assert.True(File.Exists(Path.Combine(ObjDir.Path, ProjectFileName + ".nuget.g.targets"))); 237var evaluationResult = File.ReadAllLines(evaluationResultsFile).Select(l => (l != EmptyValueMarker) ? l : "");
TestUtilities\IntegrationTestBase.cs (4)
141File.Move(originalAppHost, backupAppHost); 172File.Move(backupAppHost, originalAppHost); 212File.Move(originalAppHost, backupAppHost); 247File.Move(backupAppHost, originalAppHost);
Microsoft.Cci.Extensions (9)
Extensions\DocIdExtensions.cs (2)
89if (!File.Exists(docIdsFile)) 92foreach (string id in File.ReadAllLines(docIdsFile))
Filters\BaselineDifferenceFilter.cs (2)
26if (!File.Exists(baselineFile)) 29foreach (var line in File.ReadAllLines(baselineFile))
HostEnvironment.cs (4)
117if (File.Exists(path)) 147if (File.Exists(assemblyPath)) 153if (File.Exists(combinedPath)) 200if (File.Exists(path))
SRMetadataPEReaderCache.cs (1)
35FileStream stream = File.OpenRead(assemblyPath);
Microsoft.CodeAnalysis (27)
AssemblyUtilities.cs (2)
39if (File.Exists(satelliteAssemblyPath)) 45if (File.Exists(satelliteAssemblyPath))
CommandLine\CommandLineArguments.cs (1)
578string? resolvedPath = FileUtilities.ResolveRelativePath(reference.FilePath, basePath: null, baseDirectory: BaseDirectory, searchPaths: ReferencePaths, fileExists: File.Exists);
CommandLine\CommonCompiler.CompilerEmitStreamProvider.cs (4)
76File.Delete(_filePath); 84File.Move(_filePath, newFilePath); 87File.SetAttributes(newFilePath, FileAttributes.Hidden); 90File.Delete(newFilePath);
CommandLine\CommonCompiler.cs (1)
130if (!SuppressDefaultResponseFile(args) && File.Exists(responseFile))
Compilation.EmitStream.cs (1)
88File.Delete(tempFilePath);
DiagnosticAnalyzer\AnalyzerAssemblyLoader.Core.cs (1)
278using var stream = File.Open(assemblyPath, FileMode.Open, FileAccess.Read, FileShare.Read);
DiagnosticAnalyzer\AnalyzerAssemblyLoader.cs (1)
318if (File.Exists(filePath))
DiagnosticAnalyzer\ShadowCopyAnalyzerPathResolver.cs (2)
268if (File.Exists(originalPath)) 270File.Copy(originalPath, shadowCopyPath);
FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
FileSystem\ICommonCompilerFileSystem.cs (1)
61public bool FileExists(string filePath) => File.Exists(filePath);
FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
FileSystemExtensions.cs (4)
46using (var outputStream = FileUtilities.CreateFileStreamChecked(File.Create, outputPath, nameof(outputPath))) 47using (var pdbStream = (pdbPath == null ? null : FileUtilities.CreateFileStreamChecked(File.Create, pdbPath, nameof(pdbPath)))) 48using (var xmlDocStream = (xmlDocPath == null ? null : FileUtilities.CreateFileStreamChecked(File.Create, xmlDocPath, nameof(xmlDocPath)))) 49using (var win32ResourcesStream = (win32ResourcesPath == null ? null : FileUtilities.CreateFileStreamChecked(File.OpenRead, win32ResourcesPath, nameof(win32ResourcesPath))))
RuleSet\RuleSetInclude.cs (2)
112if (File.Exists(includePath)) 121if (File.Exists(includePath))
SourceFileResolver.cs (1)
121return File.Exists(resolvedPath);
StrongName\StrongNameFileSystem.cs (2)
34return File.ReadAllBytes(fullPath); 40return File.Exists(fullPath);
StrongName\StrongNameKeys.cs (1)
112var fileContent = ImmutableArray.Create(File.ReadAllBytes(keyFilePath));
XmlFileResolver.cs (1)
87return File.Exists(resolvedPath);
Microsoft.CodeAnalysis.Analyzers (5)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Microsoft.CodeAnalysis.AnalyzerUtilities (4)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
Microsoft.CodeAnalysis.BannedApiAnalyzers (5)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Microsoft.CodeAnalysis.CodeStyle (2)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (95)
CommandLineTestBase.cs (1)
41File.WriteAllBytes(Path.Combine(dir.Path, "mscorlib.dll"), Net461.ReferenceInfos.mscorlib.ImageBytes);
CommandLineTests.cs (78)
155Assert.True(File.Exists(exePath)); 412Assert.Equal("星野 八郎太", File.ReadAllText(Path.Combine(dir.Path, "output.txt"), Encoding.GetEncoding(932))); 432Assert.Equal("星野 八郎太", File.ReadAllText(Path.Combine(dir.Path, "output.txt"), Encoding.GetEncoding(932))); 2254var peStream = File.OpenRead(Path.Combine(dir.Path, "a.exe")); 2262AssertEx.Equal(File.ReadAllBytes(sl.Path), blob); 2286var pdbStream = File.OpenRead(Path.Combine(dir.Path, "a.pdb")); 2291AssertEx.Equal(File.ReadAllBytes(sl.Path), blob); 2315var pdbStream = File.OpenRead(Path.Combine(dir.Path, "a.pdb")); 2478using (var peReader = new PEReader(File.OpenRead(Path.Combine(dir.Path, "embed.exe")))) 2485MetadataReaderProvider.FromPortablePdbStream(File.OpenRead(Path.Combine(dir.Path, "embed.pdb")))) 2513symReader = SymReaderFactory.CreateReader(File.OpenRead(Path.Combine(dir.Path, "embed.pdb"))); 2544var content = File.ReadAllText(file, encoding ?? Encoding.UTF8); 4501using (var metadata = ModuleMetadata.CreateFromImage(File.ReadAllBytes(Path.Combine(dir.Path, "aa.exe")))) 4511if (System.IO.File.Exists(exeName)) 4513System.IO.File.Delete(exeName); 7081using (var metadata = ModuleMetadata.CreateFromImage(File.ReadAllBytes(Path.Combine(dir.Path, expectedOutputName)))) 7091if (System.IO.File.Exists(expectedOutputName)) 7093System.IO.File.Delete(expectedOutputName); 8251using (var xmlFileHandle = File.Open(xml.ToString(), FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.ReadWrite)) 8256Assert.True(File.Exists(Path.Combine(dir.ToString(), "a.xml"))); 8703System.IO.File.Delete(System.IO.Path.Combine(baseDir, "goo.dll")); 8758using (var stream = File.OpenWrite(exe.Path)) 8765using (var stream = File.OpenWrite(pdb.Path)) 8780using (var peFile = File.OpenRead(exe.Path)) 8791using (var peFile = File.OpenRead(exe.Path)) 8799using (var stream = File.OpenRead(path)) 8895using (var fsNewDll = File.OpenRead(libDll.Path)) 8910File.Delete(libSrc.Path); 8911File.Delete(libDll.Path); 8912File.Delete(libPdb.Path); 8935File.SetAttributes(libDll.Path, FileAttributes.ReadOnly); 8972using (var stream = File.OpenRead(path)) 8992return File.Open(file, mode, access, share); 9015return File.Open(file, mode, access, share); 9037return File.Open(file, mode, access, share); 9067return File.Open(file, mode, access, share); 9088return File.Open(file, mode, access, share); 9095System.IO.File.Delete(sourcePath); 9096System.IO.File.Delete(exePath); 9114return File.Open(file, (FileMode)mode, (FileAccess)access, (FileShare)share); 9120System.IO.File.Delete(sourcePath); 9121System.IO.File.Delete(exePath); 9122System.IO.File.Delete(pdbPath); 9140return File.Open(file, (FileMode)mode, (FileAccess)access, (FileShare)share); 9152System.IO.File.Delete(xmlPath); 9153System.IO.File.Delete(sourcePath); 9244var bytes = File.ReadAllBytes(xmlPath); 9263System.IO.File.Delete(xmlPath); 9264System.IO.File.Delete(sourcePath); 11370Assert.True(File.Exists(Path.Combine(dir.ToString(), "doc.xml"))); 11622Assert.True(File.Exists(exePath)); 11623Assert.True(File.Exists(pdbPath)); 11624using (var peStream = File.OpenRead(exePath)) 11803Assert.True(File.Exists(exe)); 11812Assert.True(File.Exists(doc)); 11814var content = File.ReadAllText(doc); 11836Assert.True(File.Exists(refDll)); 11867Assert.False(File.Exists(dll)); 11870Assert.False(File.Exists(refDll)); 11919Assert.True(File.Exists(refDll)); 11930Assert.False(File.Exists(pdb)); 11933Assert.True(File.Exists(doc)); 11935var content = File.ReadAllText(doc); 12295Assert.True(File.Exists(exePath)); 12296using (var peStream = File.OpenRead(exePath)) 13483Assert.True(File.Exists(binaryPath) == !warnAsError); 13486Assert.True(File.Exists(pdbPath) == !warnAsError); 13489Assert.True(File.Exists(xmlDocFilePath) == !warnAsError); 13529Assert.True(File.Exists(binaryPath) == !analyzerConfigSetToError); 13532Assert.True(File.Exists(pdbPath) == !analyzerConfigSetToError); 13535Assert.True(File.Exists(xmlDocFilePath) == !analyzerConfigSetToError); 13579Assert.True(File.Exists(binaryPath) == !rulesetSetToError); 13582Assert.True(File.Exists(pdbPath) == !rulesetSetToError); 13585Assert.True(File.Exists(xmlDocFilePath) == !rulesetSetToError); 13610Assert.True(File.Exists(binaryPath) == !warnAsError); 14047using (Stream peStream = File.OpenRead(Path.Combine(dir.Path, "checksum.exe")), pdbStream = File.OpenRead(Path.Combine(dir.Path, "checksum.pdb"))) 14406string[] writtenText = File.ReadAllLines(Path.Combine(dir.Path, "touched.write"));
SarifErrorLoggerTests.cs (9)
55var actualOutput = File.ReadAllText(errorLogFile).Trim(); 88var actualOutput = File.ReadAllText(errorLogFile).Trim(); 123var actualOutput = File.ReadAllText(errorLogFile).Trim(); 157var actualOutput = File.ReadAllText(errorLogFile).Trim(); 193var actualOutput = File.ReadAllText(errorLogFile).Trim(); 228var actualOutput = File.ReadAllText(errorLogFile).Trim(); 263var actualOutput = File.ReadAllText(errorLogFile).Trim(); 298var actualOutput = File.ReadAllText(errorLogFile).Trim(); 330var actualOutput = File.ReadAllText(errorLogFile).Trim();
SarifV2ErrorLoggerTests.cs (5)
463var actualOutput = File.ReadAllText(errorLogFile).Trim(); 545var actualOutput = File.ReadAllText(errorLogFile).Trim(); 615var actualOutput = File.ReadAllText(errorLogFile).Trim(); 669Assert.False(File.Exists(Path.Combine(mappedDir.Path, "otherfile.cs"))); 693var actualOutput = File.ReadAllText(errorLogFile).Trim();
TouchedFileLoggingTests.cs (2)
236File.ReadAllText(touchedReadPath).Trim()); 240File.ReadAllText(touchedWritesPath).Trim());
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (31)
PdbSourceDocument\AbstractPdbSourceDocumentTests.cs (3)
277File.WriteAllText(sourceCodePaths[i], sources[i].ToString(), sources[i].Encoding); 316using var dllStream = FileUtilities.CreateFileStreamChecked(File.Create, dllFilePath, nameof(dllFilePath)); 317using var pdbStream = (pdbFilePath == null ? null : FileUtilities.CreateFileStreamChecked(File.Create, pdbFilePath, nameof(pdbFilePath)));
PdbSourceDocument\ImplementationAssemblyLookupServiceTests.cs (10)
46File.WriteAllText(Path.Combine(dataDir, "FrameworkList.xml"), """ 80File.WriteAllText(Path.Combine(dataDir, "FrameworkList.xml"), """ 118File.WriteAllText(Path.Combine(dataDir, "FrameworkList.xml"), """ 389File.WriteAllBytes(typeForwardDllFilePath, []); 390File.WriteAllBytes(dllFilePath, []); 450File.WriteAllBytes(typeForwardDllFilePath, []); 451File.WriteAllBytes(dllFilePath, []); 521File.WriteAllBytes(typeForwardDllFilePath, []); 522File.WriteAllBytes(realImplementationDllFilePath, []); 523File.WriteAllBytes(dllFilePath, []);
PdbSourceDocument\PdbFileLocatorServiceTests.cs (3)
33File.Move(GetPdbPath(path), pdbFilePath); 60File.Move(GetPdbPath(path), pdbFilePath); 85File.Move(GetPdbPath(path), pdbFilePath);
PdbSourceDocument\PdbSourceDocumentLoaderServiceTests.cs (3)
36File.Move(GetSourceFilePath(path), sourceFilePath); 42var fileHash = hash.ComputeHash(File.ReadAllBytes(sourceFilePath)); 67File.Move(GetSourceFilePath(path), sourceFilePath);
PdbSourceDocument\PdbSourceDocumentTests.cs (12)
360File.WriteAllText(Path.Combine(dataDir, "FrameworkList.xml"), """ 401File.WriteAllText(Path.Combine(dataDir, "FrameworkList.xml"), """ 459File.WriteAllText(Path.Combine(dataDir, "FrameworkList.xml"), """ 484File.Delete(GetPdbPath(path)); 507File.Delete(GetDllPath(path)); 529File.Delete(GetSourceFilePath(path)); 572File.WriteAllBytes(GetPdbPath(path), []); 597File.WriteAllBytes(GetPdbPath(path), corruptPdb); 621File.Move(pdbFilePath, archivePdbFilePath); 632File.Delete(pdbFilePath); 633File.Move(archivePdbFilePath, pdbFilePath); 652File.WriteAllText(GetSourceFilePath(path), """
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (2)
Emit\CompilationEmitTests.cs (2)
4643Assert.True(File.Exists(dllPath), "DLL does not exist"); 4644Assert.True(File.Exists(pdbPath), "PDB does not exist");
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (4)
Emit\EditAndContinue\EditAndContinueTestBase.cs (4)
259File.WriteAllBytes(Path.Combine(outputDirectory, baseName + ".dll" + extSuffix), baseline.EmittedAssemblyData.ToArray()); 260File.WriteAllBytes(Path.Combine(outputDirectory, baseName + ".pdb" + extSuffix), baseline.EmittedAssemblyPdb.ToArray()); 264File.WriteAllBytes(Path.Combine(outputDirectory, $"{baseName}.{i + 1}.metadata{extSuffix}"), diffs[i].MetadataDelta.ToArray()); 265File.WriteAllBytes(Path.Combine(outputDirectory, $"{baseName}.{i + 1}.pdb{extSuffix}"), diffs[i].PdbDelta.ToArray());
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Attributes\AttributeTests_Security.cs (1)
1623using (var fileStream = File.Open(filePath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None))
Microsoft.CodeAnalysis.CSharp.Features (3)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (3)
234using var stream = File.OpenRead(filePath); 245using var stream = File.Open(Path, FileMode.Create, FileAccess.Write); 487else if (!File.Exists(resolvedProjectPath))
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
EditAndContinue\StatementEditingTests.cs (1)
4006delegateDefs = MetadataReference.CreateFromImage(File.ReadAllBytes(tempAssembly.Path));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (1)
InteractiveSessionReferencesTests.cs (1)
143File.Move(libBFile.Path, Path.Combine(dir.Path, "libB.dll"));
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (4)
DocumentationComments\DocumentationCommentCompilerTests.cs (2)
4901using (File.Open(xmlFilePath, FileMode.Open, FileAccess.Write, FileShare.None)) 4938using (File.Open(xmlFilePath1, FileMode.Open, FileAccess.Write, FileShare.None))
Symbols\CompilationCreationTests.cs (1)
2661if (File.Exists(reference))
Symbols\TypeResolutionTests.cs (1)
122MetadataReference.CreateFromImage(File.ReadAllBytes(typeof(TypeTests).GetTypeInfo().Assembly.Location))
Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests (2)
Metadata\WinMdDumpTest.cs (2)
459File.WriteAllText(fileExpected, expected); 460File.WriteAllText(fileActual, actual);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (2)
DirectoryExtensions.cs (2)
26File.SetAttributes(file, FileAttributes.Normal); 27File.Delete(file);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (6)
EditAndContinue\EditAndContinueLanguageServiceTests.cs (1)
390File.WriteAllText(sourceFile.Path, "class C1 { void M() { System.Console.WriteLine(\"b\"); } }", Encoding.UTF8);
MetadataAsSource\AbstractMetadataAsSourceTests.TestContext.cs (4)
120Assert.True(File.Exists(portableExecutable.FilePath), $"'{portableExecutable.FilePath}' does not exist for reference '{portableExecutable.Display}'"); 125Assert.True(File.Exists(reference.Display), $"'{reference.Display}' does not exist"); 139var actual = File.ReadAllText(file.FilePath).Trim(); 304using var reader = File.OpenRead(file.FilePath);
Utilities\SymbolEquivalenceComparerTests.cs (1)
1937var bytes = File.ReadAllBytes(tempAssembly.Path);
Microsoft.CodeAnalysis.ExternalAccess.Razor.Features (2)
RazorAnalyzerAssemblyResolver.cs (2)
66if (File.Exists(onDiskName)) 99if (File.Exists(assemblyPath))
Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests (1)
RazorAnalyzerAssemblyResolverTests.cs (1)
106File.Move(Path.Combine(dir1, fileName), Path.Combine(dir2, fileName));
Microsoft.CodeAnalysis.Features (22)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.AbstractGlobalSuppressMessageCodeAction.cs (1)
100if (hasDocWithSuppressionsName || File.Exists(suppressionsFilePath))
Completion\FileSystemCompletionHelper.cs (1)
83return IOUtilities.PerformIO(() => (File.GetAttributes(fullPath) & (FileAttributes.Hidden | FileAttributes.System)) == 0, false);
Diagnostics\Service\DiagnosticAnalyzerComparer.cs (2)
39if (path == null || !File.Exists(path)) 42return File.GetLastWriteTimeUtc(path);
EditAndContinue\TraceLog.cs (2)
45File.AppendAllLines(path, [entry]); 84File.WriteAllBytes(path, [.. bytes]);
MetadataAsSource\DecompilationMetadataAsSourceFileProvider.cs (2)
111if (!File.Exists(fileInfo.TemporaryFilePath)) 187if (!skipWritingFile && !File.Exists(fileInfo.TemporaryFilePath))
PdbSourceDocument\ImplementationAssemblyLookupService.cs (5)
69while (File.Exists(dllPath)) 88using var fileStream = File.OpenRead(dllPath); 137if (IOUtilities.PerformIO(() => File.Exists(pathToTry))) 161using var fr = File.OpenRead(frameworkXml); 183if (IOUtilities.PerformIO(() => File.Exists(dllPath)))
PdbSourceDocument\PdbFileLocatorService.cs (3)
79pdbStream = IOUtilities.PerformIO(() => File.OpenRead(pdbResult.PdbFilePath)); 126if (File.Exists(fileName)) 127return File.OpenRead(fileName);
PdbSourceDocument\PdbSourceDocumentLoaderService.cs (3)
56if (File.Exists(filePath) && 94using (var file = File.OpenWrite(filePath)) 172if (PathUtilities.IsAbsolute(sourceDocument.FilePath) && File.Exists(sourceDocument.FilePath))
SymbolSearch\Windows\SymbolSearchUpdateEngine.IOService.cs (3)
20public byte[] ReadAllBytes(string path) => File.ReadAllBytes(path); 23=> File.Replace(sourceFileName, destinationFileName, destinationBackupFileName, ignoreMetadataErrors); 26=> File.Move(sourceFileName, destinationFileName);
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
EditAndContinue\EditAndContinueWorkspaceTestBase.cs (1)
465using var stream = File.OpenRead(path);
Microsoft.CodeAnalysis.Features.UnitTests (4)
EditAndContinue\EditAndContinueWorkspaceServiceTests.cs (4)
1000using var stream = File.OpenRead(moduleFile.Path); 1157using var fileLock = File.Open(sourceFile.Path, FileMode.Open, FileAccess.Read, FileShare.None); 1991File.WriteAllText(sourceFilePath, source3, Encoding.UTF8); 4380File.WriteAllText(sourcePath, source2, Encoding.UTF8);
Microsoft.CodeAnalysis.InteractiveHost (4)
Interactive\Core\InteractiveHost.Service.cs (3)
520if (File.Exists(initializationFilePath)) 627return File.Exists(file); 711using var reader = File.OpenText(fullPath);
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
Microsoft.CodeAnalysis.LanguageServer (13)
CustomExportAssemblyLoader.cs (1)
125if (!File.Exists(codeBasePath))
DotnetCliHelper.cs (2)
120Contract.ThrowIfFalse(File.Exists(vstestConsole), $"VSTestConsole was not found at {vstestConsole}"); 142if (File.Exists(filePath))
FileBasedPrograms\CanonicalMiscFilesProjectLoader.cs (1)
68File.WriteAllText(documentPath, string.Empty);
HostWorkspace\LanguageServerWorkspaceFactory.cs (1)
93if (File.Exists(analyzerPath))
HostWorkspace\LoadedProject.cs (1)
111using var assetsFileStream = File.OpenRead(filePath);
HostWorkspace\ProjectDependencyHelper.cs (1)
52if (!File.Exists(projectAssetsPath))
HostWorkspace\ProjectTelemetry\ProjectLoadTelemetryReporter.cs (1)
151var content = await File.ReadAllTextAsync(projectToLoad.Path);
Services\ExtensionAssemblyManager.cs (3)
87if (!File.Exists(assemblyFilePath)) 149if (File.Exists(assemblyPath)) 214if (File.Exists(assemblyPath))
Testing\RunTestsHandler.cs (2)
45Contract.ThrowIfFalse(File.Exists(projectOutputPath), $"Output path {projectOutputPath} is missing"); 179var contents = await File.ReadAllTextAsync(runSettingsPath, cancellationToken);
Microsoft.CodeAnalysis.LanguageServer.Protocol (3)
Features\DecompiledSource\AssemblyResolver.cs (2)
140if (File.Exists(reference.Display)) 158if (!File.Exists(moduleFileName))
Handler\InlineCompletions\XmlSnippetParser.cs (1)
92if (!File.Exists(path))
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (1)
InlineCompletions\TestSnippetInfoService.cs (1)
29if (!File.Exists(snippetsFile))
Microsoft.CodeAnalysis.LanguageServer.UnitTests (2)
Utilities\AbstractLanguageServerClientTests.cs (2)
50await File.WriteAllTextAsync(projectPath, $""" 61await File.WriteAllTextAsync(codePath, code);
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (5)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Microsoft.CodeAnalysis.PublicApiAnalyzers (4)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
Microsoft.CodeAnalysis.Remote.ServiceHub (4)
Host\RemoteAnalyzerPathResolver.cs (1)
23=> File.Exists(GetFixedPath(originalAnalyzerPath));
src\VisualStudio\Core\Def\UnusedReferences\ProjectAssets\ProjectAssetsFileReader.cs (2)
22var doesProjectAssetsFileExist = IOUtilities.PerformIO(() => File.Exists(projectAssetsFilePath)); 30using var fileStream = File.OpenRead(projectAssetsFilePath);
src\VisualStudio\Core\Def\Watson\FaultReporter.cs (1)
330var lastWrite = File.GetLastWriteTimeUtc(path);
Microsoft.CodeAnalysis.Remote.Workspaces (3)
ExportProviderBuilder.cs (3)
56if (File.Exists(compositionCacheFile)) 134hashContents.Append(File.GetLastWriteTimeUtc(assemblyPath).ToString("F")); 166File.Move(tempFilePath, compositionCacheFile);
Microsoft.CodeAnalysis.ResxSourceGenerator (4)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests (2)
Verifiers\CSharpSourceGeneratorVerifier`1+Test.cs (1)
141File.WriteAllText(filePath, tree.GetText().ToString(), tree.Encoding);
Verifiers\VisualBasicSourceGeneratorVerifier`1+Test.cs (1)
126File.WriteAllText(filePath, tree.GetText().ToString(), tree.Encoding);
Microsoft.CodeAnalysis.Scripting (15)
Hosting\AssemblyLoader\InteractiveAssemblyLoader.cs (1)
333if (File.Exists(path))
Hosting\AssemblyLoader\MetadataShadowCopyProvider.cs (5)
513if (File.Exists(dir) || Directory.Exists(dir)) 527if (File.Exists(dir)) 593if (File.Exists(Path.Combine(assemblyDirectory, docSubdirectory, docFileName))) 603if (File.Exists(Path.Combine(assemblyDirectory, docFileName))) 616File.Copy(originalPath, shadowCopyPath, overwrite: true);
Hosting\Resolvers\RuntimeMetadataReferenceResolver.cs (2)
126if (File.Exists(fullPath)) 198=> TrustedPlatformAssemblies.TryGetValue(name, out var path) && File.Exists(path) ? CreateFromFile(path, properties) : null;
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\Compilers\Shared\GlobalAssemblyCacheHelpers\GacFileResolver.cs (1)
77return File.Exists(path) ? path : null;
src\Compilers\Shared\GlobalAssemblyCacheHelpers\MonoGlobalAssemblyCache.cs (5)
46if (!File.Exists(corlibFriendPath)) 54if (File.Exists(corlibFriendPath)) 89if (File.Exists(assemblyPath)) 112if (!File.Exists(assemblyPath)) 189if (!File.Exists(assemblyPath))
Microsoft.CodeAnalysis.Scripting.Desktop.UnitTests (9)
MetadataShadowCopyProviderTests.cs (9)
95Assert.Equal(File.ReadAllBytes(dll.Path), File.ReadAllBytes(sc1.PrimaryModule.FullPath)); 96Assert.Equal(File.ReadAllBytes(doc.Path), File.ReadAllBytes(sc1.DocumentationFile.FullPath)); 160Assert.Throws<IOException>(() => File.Delete(sc)); 169File.SetLastWriteTimeUtc(path0, DateTime.Now + TimeSpan.FromHours(1)); 231Assert.Equal("Invariant", File.ReadAllText(sc.DocumentationFile.FullPath)); 237Assert.Equal("Greek", File.ReadAllText(sc.DocumentationFile.FullPath)); 243Assert.Equal("Invariant", File.ReadAllText(sc.DocumentationFile.FullPath));
Microsoft.CodeAnalysis.Scripting.TestUtilities (3)
TestRuntimeMetadataReferenceResolver.cs (3)
32if (File.Exists(testDependencyAssemblyPath)) 39if (File.Exists(fxAssemblyPath)) 51if (File.Exists(reference))
Microsoft.CodeAnalysis.SemanticSearch.Extensions (1)
ProjectModel.cs (1)
114return File.ReadAllText(FilePath, Encoding.UTF8);
Microsoft.CodeAnalysis.Test.Utilities (24)
Assert\ArtifactUploadUtil.cs (2)
85File.Copy(filePath, Path.Combine(uploadDir, fileName)); 105File.Copy(filePath, destFilePath);
Assert\AssertEx.cs (7)
592File.WriteAllText(file1, result1); 595File.WriteAllText(file2, result2); 845var testFileLines = File.ReadAllLines(expectedValueSourcePath); 847File.WriteAllLines(actualFile, testFileLines.Take(expectedValueSourceLine)); 848File.AppendAllText(actualFile, actualString); 849File.AppendAllLines(actualFile, testFileLines.Skip(expectedValueSourceLine + expectedLineCount)); 865File.WriteAllText(compareCmd, string.Format("\"{0}\" \"{1}\" \"{2}\"", s_diffToolPath, actualFilePath, expectedFilePath));
CommonTestBase.cs (1)
209return ImmutableArray.Create<byte>(File.ReadAllBytes(path));
CompilationVerifier.cs (1)
262File.WriteAllText(Path.Combine(dumpDirectory, "log.txt"), sb.ToString());
DotNetCoreSdk.cs (1)
29&& File.Exists(Path.Combine(directory, dotNetExeName));
Metadata\MetadataReaderUtils.cs (1)
485using (var peStream = File.OpenRead(pePath))
Platform\CoreClr\AssemblyLoadContextUtils.cs (1)
33if (File.Exists(assemblyPath))
SharedResourceHelpers.cs (1)
27System.IO.File.Delete(f);
TempFiles\DisposableFile.cs (1)
33File.Delete(Path);
TempFiles\TempDirectory.cs (1)
81File.Copy(originalPath, filePath);
TempFiles\TempFile.cs (7)
72File.WriteAllText(_path, content, encoding); 78File.WriteAllText(_path, content); 84using (var sw = new StreamWriter(File.Create(_path), encoding)) 99File.WriteAllBytes(_path, content); 111return File.ReadAllText(_path); 116return File.ReadAllBytes(_path); 121return WriteAllBytes(File.ReadAllBytes(path));
Microsoft.CodeAnalysis.UnitTests (24)
AnalyzerAssemblyLoaderTests.cs (8)
1424File.Copy(assembly.Location, destFile, overwrite: true); 1464File.Delete(deltaCopy); 1468Assert.Throws<UnauthorizedAccessException>(() => File.Delete(testFixture.Delta1)); 1489File.Delete(deltaCopy); 1533File.Delete(delta1File); 1534File.Delete(delta2File); 1535File.Delete(gammaFile); 1583File.WriteAllBytes(path, new byte[] { 42 });
AssemblyUtilitiesTests.cs (1)
34var assembly = Assembly.Load(File.ReadAllBytes(_testFixture.Alpha));
MetadataReferences\FusionAssemblyPortabilityPolicy.cs (1)
52var hash = CryptographicHashProvider.ComputeSha1(File.ReadAllBytes(appConfigPath));
MetadataReferences\MetadataReferenceTests.cs (4)
96var stream = File.OpenRead(file.Path); 110File.Delete(file.Path); 176File.Delete(file.Path); 199File.Delete(file.Path);
ShadowCopyAnalyzerPathResolverTests.cs (9)
57Assert.False(File.Exists(shadowPath)); 64File.WriteAllText(analyzerPath, "test"); 66Assert.True(File.Exists(shadowPath)); 67Assert.Equal("test", File.ReadAllText(shadowPath)); 79File.WriteAllText(analyzer1Path, "test"); 81File.WriteAllText(analyzer2Path, "test"); 96Assert.Equal("group1-analyzer.dll", File.ReadAllText(group1ShadowPath)); 97Assert.Equal("group2-analyzer.dll", File.ReadAllText(group2ShadowPath)); 104File.WriteAllText(filePath, $"{Path.GetFileName(groupName)}-{name}");
Text\StringTextDecodingTests.cs (1)
306File.WriteAllText(tmpFile.Path, expectedText, encoding);
Microsoft.CodeAnalysis.VisualBasic (1)
CommandLine\VisualBasicCommandLineParser.vb (1)
1600If File.Exists(filePath) Then
Microsoft.CodeAnalysis.Workspaces (12)
Rename\ConflictEngine\MutableConflictResolution.cs (2)
102if (File.Exists(document.FilePath)) 109while (File.Exists(newDocumentFilePath))
src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerAssemblyLoader.Core.cs (1)
278using var stream = File.Open(assemblyPath, FileMode.Open, FileAccess.Read, FileShare.Read);
src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerAssemblyLoader.cs (1)
318if (File.Exists(filePath))
src\Compilers\Core\Portable\DiagnosticAnalyzer\ShadowCopyAnalyzerPathResolver.cs (2)
268if (File.Exists(originalPath)) 270File.Copy(originalPath, shadowCopyPath);
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Storage\SQLite\v2\SQLitePersistentStorage.cs (1)
151return File.Open(
Utilities\Documentation\XmlDocumentationProvider.cs (1)
49if (!File.Exists(xmlDocCommentFilePath))
Workspace\ProjectSystem\ProjectSystemProjectFactory.cs (1)
118? VersionStamp.Create(File.GetLastWriteTimeUtc(creationInfo.FilePath))
Microsoft.CodeAnalysis.Workspaces.MSBuild (16)
MSBuild\BuildHostProcessManager.cs (3)
34private static bool IsLoadedFromNuGetPackage => File.Exists(Path.Combine(MSBuildWorkspaceDirectory, "..", "..", "microsoft.codeanalysis.workspaces.msbuild.nuspec")); 156if (dotnetPath is null || processPath == dotnetPath || !File.Exists(dotnetPath)) 311if (!File.Exists(buildHostPath))
MSBuild\MSBuildProjectLoader.Worker.cs (1)
419if (fullPath != null && File.Exists(fullPath))
MSBuild\MSBuildProjectLoader.Worker_ResolveReferences.cs (5)
321if (outputRefFilePath != null && !File.Exists(outputRefFilePath)) 327if (outputFilePath != null && !File.Exists(outputFilePath)) 347&& File.Exists(outputFilePath); 360if ((builder.Contains(outputFilePath) && File.Exists(outputFilePath)) || 361(builder.Contains(outputRefFilePath) && File.Exists(outputRefFilePath)))
MSBuild\MSBuildWorkspace.cs (2)
528if (File.Exists(fullPath)) 530File.Delete(fullPath);
MSBuild\PathResolver.cs (2)
34if (!File.Exists(absolutePath)) 59if (!File.Exists(absolutePath))
MSBuild\SolutionFileReader.SolutionFilterReader.cs (2)
27using var document = JsonDocument.Parse(File.ReadAllText(filterFilename)); 40if (!File.Exists(solutionFilename))
src\Workspaces\MSBuild\BuildHost\Rpc\Contracts\MonoMSBuildDiscovery.cs (1)
79.FirstOrDefault(File.Exists);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (2)
Rpc\Contracts\MonoMSBuildDiscovery.cs (1)
79.FirstOrDefault(File.Exists);
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (31)
MSBuildWorkspaceTestBase.cs (1)
135if (!File.Exists(p1.OutputFilePath))
NetCoreTests.cs (3)
130var content = File.ReadAllText(projectFilePath); 131File.Delete(projectFilePath); 573Assert.True(File.Exists(depsJsonFile), $"{depsJsonFile} should exist, or it won't load on some runtimes.");
NewlyCreatedProjectsFromDotNetNew.cs (2)
42if (File.Exists(globalJsonPath)) 219File.Copy(s_globalJsonPath, tempGlobalJsonPath);
ProjectGuardFiles.cs (5)
19File.WriteAllText(Path.Combine(Path.GetTempPath(), "global.json"), 26File.WriteAllText(Path.Combine(Path.GetTempPath(), "Directory.Build.props"), 44File.WriteAllText(Path.Combine(Path.GetTempPath(), "Directory.Build.rsp"), 49File.WriteAllText(Path.Combine(Path.GetTempPath(), "Directory.Build.targets"), 58File.WriteAllText(Path.Combine(Path.GetTempPath(), "NuGet.Config"),
VisualStudioMSBuildWorkspaceTests.cs (20)
323Assert.False(File.Exists(p1.OutputFilePath)); 959var file = File.Open(sourceFile, FileMode.Open, FileAccess.Write, FileShare.None); 994using var file = File.Open(sourceFile, FileMode.Open, FileAccess.Write, FileShare.None); 1984Assert.True(File.Exists(fooDoc.FilePath)); 1985var text = File.ReadAllText(fooDoc.FilePath); 2013var textOnDisk = File.ReadAllText(document2.FilePath); 2017var projectFileText = File.ReadAllText(project2.FilePath); 2055var textOnDisk = File.ReadAllText(document2.FilePath); 2084Assert.False(File.Exists(document.FilePath)); 2114var textOnDisk = File.ReadAllText(document.FilePath); 2141var textOnDisk = File.ReadAllText(document.FilePath); 2167var textOnDisk = File.ReadAllText(document2.FilePath); 2598using (File.Open(projectFile, FileMode.Open, FileAccess.ReadWrite)) 2917var projFileText = File.ReadAllText(projFile); 2930projFileText = File.ReadAllText(projFile); 2935projFileText = File.ReadAllText(projFile); 2945var projFileText = File.ReadAllText(projFile); 2958projFileText = File.ReadAllText(projFile); 2965projFileText = File.ReadAllText(projFile); 3381var bytes = File.ReadAllBytes(fullPath);
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (1)
Workspaces\TestWorkspace_XmlConsumption.cs (1)
809var content = File.ReadAllBytes(reference.Value);
Microsoft.CodeAnalysis.Workspaces.UnitTests (2)
SolutionTests\SolutionWithSourceGeneratorTests.cs (2)
1475using (var destination = File.OpenWrite(analyzerPath)) 1494using (var destination = File.OpenWrite(analyzerPath))
Microsoft.Data.Analysis (1)
TextFieldParser.cs (1)
585if (!File.Exists(path))
Microsoft.Data.Analysis.Tests (3)
DataFrame.IOTests.cs (2)
1333if (File.Exists(SQLitePath)) 1334File.Delete(SQLitePath);
src\Microsoft.Data.Analysis\TextFieldParser.cs (1)
585if (!File.Exists(path))
Microsoft.DotNet.Arcade.Sdk (23)
src\CheckRequiredDotNetVersion.cs (2)
48lastWrite = File.GetLastWriteTimeUtc(globalJsonPath); 73globalJson = File.ReadAllText(globalJsonPath);
src\DownloadFile.cs (4)
62if (File.Exists(DestinationPath) && !Overwrite) 115if (File.Exists(filePath)) { 117File.Copy(filePath, DestinationPath, overwrite: true); 198using (var outStream = File.Create(DestinationPath))
src\ExtractNgenMethodList.cs (1)
97using (var stream = File.Open(AssemblyFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
src\GenerateChecksums.cs (3)
34if (!File.Exists(item.ItemSpec)) 42using (FileStream stream = File.OpenRead(item.ItemSpec)) 48File.WriteAllText(destinationPath, checksum);
src\GenerateResxSource.cs (1)
364File.WriteAllText(OutputPath, result);
src\GenerateSourcePackageSourceLinkTargetsFile.cs (1)
38File.WriteAllText(OutputPath, GetOutputFileContent(), Encoding.UTF8);
src\InstallDotNetCore.cs (4)
45if (!File.Exists(GlobalJsonPath)) 50if (!File.Exists(DotNetInstallScript)) 56var jsonContent = File.ReadAllText(GlobalJsonPath); 84if (!File.Exists(VersionsPropsPath))
src\LocateDotNet.cs (3)
47var lastWrite = File.GetLastWriteTimeUtc(globalJsonPath); 58var globalJson = File.ReadAllText(globalJsonPath); 71var dotNetDir = paths.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(p => File.Exists(Path.Combine(p, fileName)));
src\SetCorFlags.cs (1)
80using (var stream = File.Open(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
src\Unsign.cs (1)
47using (var stream = File.Open(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
src\ValidateLicense.cs (2)
38var actualLines = File.ReadAllLines(LicensePath, Encoding.UTF8); 39var expectedLines = File.ReadAllLines(ExpectedLicensePath, Encoding.UTF8);
Microsoft.DotNet.Arcade.Sdk.Tests (7)
GenerateResxSourceTests.cs (5)
47if (File.Exists(actualFile)) 49File.Delete(actualFile); 56Assert.True(File.Exists(actualFile), "Actual file does not exist"); 57var actualFileContents = File.ReadAllText(actualFile); 59Assert.Equal(File.ReadAllText(expectedFile), actualFileContents, ignoreLineEndingDifferences: true);
GetLicenseFilePathTests.cs (1)
22File.WriteAllText(licensePath, "");
Utilities\TestApp.cs (1)
114File.Copy(srcFileName, destFileName);
Microsoft.DotNet.ArcadeAzureIntegration (1)
DefaultIdentityTokenCredential.cs (1)
135File.WriteAllText(tokenFileName, idToken);
Microsoft.DotNet.Baselines.Tasks (3)
PRCreator.cs (3)
139if (!File.Exists(updatedFile)) 183var updatedFileLines = File.ReadAllLines(filePath); 244string? content = File.ReadAllText(filePath);
Microsoft.DotNet.Build.Manifest.Tests (4)
BuildModelFactoryTests.cs (2)
572if (File.Exists(tempXmlFile)) 574File.Delete(tempXmlFile);
TestInputs\TestInputs.cs (1)
21return File.ReadAllBytes(path);
VersionIdentiferTests.cs (1)
67string[] assets = File.ReadAllLines("TestInputs/Versions/VersionIdentifierTestsAssets.csv");
Microsoft.DotNet.Build.Tasks.Feed (23)
src\AzureStorageExtensions.cs (2)
20using var stream = File.OpenRead(filename); 44using Stream localFileStream = File.OpenRead(file);
src\common\AzureStorageUtils.cs (2)
90using (var stream = File.OpenRead(filename)) 254using (Stream localFileStream = File.OpenRead(localPackageFullPath))
src\common\UploadToAzure.cs (2)
97if (!File.Exists(item.ItemSpec)) 119using (Stream localFileStream = File.OpenRead(item.ItemSpec))
src\ConfigureInputFeed.cs (1)
42using (StreamWriter swriter = new StreamWriter(File.Create(nugetConfigLocation)))
src\PublishArtifactsInManifest.cs (2)
393X509CertificateLoader.LoadPkcs12(Convert.FromBase64String(File.ReadAllText(AkaMSClientCertificate)), password: null) : null, 443X509CertificateLoader.LoadPkcs12(Convert.FromBase64String(File.ReadAllText(AkaMSClientCertificate)), password: null) : null,
src\PublishArtifactsInManifestBase.cs (9)
746if (!File.Exists(symbolPublishingExclusionsFile)) 755string[] files = File.ReadAllLines(symbolPublishingExclusionsFile); 830File.Copy(looseFile, looseFileStagePath.FullName); 1231if (!File.Exists(localPackagePath)) 1303if (!File.Exists(localPackagePath)) 1514using (Stream packageStream = File.OpenRead(localPackageLocation)) 1696if (!File.Exists(localBlobPath)) 1750if (!File.Exists(localBlobPath)) 1842File.Delete(file);
src\PublishSignedAssets.cs (2)
87using (BinaryReader reader = new BinaryReader(File.Open(packagePath, FileMode.Open))) 99if (!File.Exists(localPackagePath))
src\PushToBuildStorage.cs (3)
587File.Copy(sourceFileName, destFileName, overwrite); 592File.Copy(sourceFileName, destFileName, overwrite); 607File.SetAttributes(destFile.FullName, FileAttributes.Normal);
Microsoft.DotNet.Build.Tasks.Feed.Tests (6)
DownloadFileTests.cs (5)
87File.Exists(path).Should().BeTrue(); 156File.Exists(path).Should().BeTrue(); 231File.Exists(path).Should().BeTrue(); 241File.Exists(path2).Should().BeTrue(); 434File.Exists(path).Should().BeTrue();
src\Microsoft.DotNet.Build.Manifest.Tests\TestInputs\TestInputs.cs (1)
21return File.ReadAllBytes(path);
Microsoft.DotNet.Build.Tasks.Installers (37)
src\CreateChangelogFile.cs (1)
40using GZipStream stream = new(File.Create(ChangelogOutputPath), CompressionLevel.Optimal);
src\CreateControlFile.cs (1)
45using Stream stream = File.Create(ControlFileOutputPath);
src\CreateDebPackage.cs (3)
34using ArWriter arWriter = new(File.Open(OutputDebPackagePath, FileMode.Create), false); 36using Stream controlFile = File.OpenRead(ControlFile.ItemSpec); 38using Stream dataFile = File.OpenRead(DataFile.ItemSpec);
src\CreateLightCommandPackageDrop.cs (1)
55File.Copy(WixProjectFile, destinationPath, true);
src\CreateMD5SumsFile.cs (2)
32using FileStream outputFile = File.Create(OutputFile); 38using FileStream fileStream = File.OpenRead(file.ItemSpec);
src\CreateRpmPackage.cs (2)
116builder.AddScript(script.GetMetadata("Kind"), File.ReadAllText(script.ItemSpec)); 119using (CpioReader reader = new(File.OpenRead(Payload), leaveOpen: false))
src\CreateWixBuildWixpack.cs (18)
115File.Copy(projectPath, destPath, overwrite: true); 148if (File.Exists(OutputFile)) 150File.Delete(OutputFile); 202File.Copy(includeFile, tempFilePath, overwrite: true); 212File.Delete(tempFilePath); 432File.WriteAllText(Path.Combine(WixpackWorkingDir, "create.rsp"), string.Join(System.Environment.NewLine, commandLineArgs)); 446File.WriteAllText(Path.Combine(WixpackWorkingDir, "create.cmd"), createCmdFileContents.ToString()); 511if (!File.Exists(xmlPath)) 519File.Copy(xmlPath, copiedXmlPath, overwrite: true); 639string content = File.ReadAllText(file); 649if (File.Exists(includeFilePath)) 667if (File.Exists(potentialPath)) 683File.WriteAllText(file, content); 749string input = File.ReadAllText(sourceFile); 933File.WriteAllText(sourceFile, output.ToString()); 1021if (File.Exists(source)) 1024File.Copy(source, destPath, overwrite: true); 1108File.Copy(file, Path.Combine(destDir, Path.GetFileName(file)), overwrite: true);
src\CreateWixCommandPackageDropBase.cs (8)
68if(File.Exists(OutputFile)) 70File.Delete(OutputFile); 129File.WriteAllText(commandFilename, commandString.ToString()); 145File.Copy(wixSrcFile.ItemSpec, newWixSrcFilePath, true); 177File.Copy(locItem.ItemSpec, destinationPath, true); 293if (File.Exists(possiblePath)) 301else if (File.Exists(oldPath)) 331File.Copy(oldPath, Path.Combine(outputPath, newRelativePath), true);
src\GenerateMacOSDistributionFile.cs (1)
120using XmlWriter writer = XmlWriter.Create(File.Create(DestinationFile));
Microsoft.DotNet.Build.Tasks.Packaging (23)
GenerateNuSpec.cs (4)
125using (var file = File.Create(OutputFileName)) 133if (!File.Exists(OutputFileName)) 138var oldSource = Encoding.UTF8.GetString(File.ReadAllBytes(OutputFileName)); 181using (var stream = File.OpenRead(InputFileName))
GetApplicableAssetsFromPackages.cs (1)
208if (File.Exists(pdbPath))
GetAssemblyReferences.cs (1)
50if (!File.Exists(assemblyItem.ItemSpec))
GetLayoutFiles.cs (1)
139if (File.Exists(symbolSource))
GetPackageDescription.cs (1)
55if (!File.Exists(descriptionPath))
GetRuntimeJsonValues.cs (2)
31if (string.IsNullOrEmpty(JsonFilename) || !File.Exists(JsonFilename)) 34JObject jObject = JObject.Parse(File.ReadAllText(JsonFilename));
GetRuntimeTargets.cs (2)
30if (string.IsNullOrEmpty(JsonFilename) || !File.Exists(JsonFilename)) 33JObject jObject = JObject.Parse(File.ReadAllText(JsonFilename));
NuGetPack.cs (4)
166if (!File.Exists(nuspecPath)) 202using (var nuspecFile = File.Open(nuspecPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)) 308using (var fileStream = File.Create(nupkgPath)) 362file.Source = File.Exists(packedPackageSourcePath) ? packedPackageSourcePath : fileName;
PackageIndex.cs (2)
67using (var file = File.OpenText(packageIndexFile)) 84using (var file = File.CreateText(path))
PackageItem.cs (1)
76if (_version == null && IsDll && File.Exists(SourcePath))
PackageMetadata.cs (1)
18string packageMetadata = File.ReadAllText(path);
PackageReport.cs (2)
40using (var file = File.CreateText(path)) 55using (var file = File.OpenText(path))
UpdatePackageIndex.cs (1)
91PackageIndex index = File.Exists(indexFilePath) ?
Microsoft.DotNet.Build.Tasks.Packaging.Tests (10)
GenerateNuSpecAndPackTests.cs (4)
30if (File.Exists(nuspec)) 32File.Delete(nuspec); 45File.Exists(nuspec).Should().BeTrue(); 54File.Exists($"{generateNuSpec.Id}.{generateNuSpec.Version}.nupkg").Should().BeTrue();
PackageIndexTests.cs (3)
26DateTime originalModifiedTime = File.GetLastWriteTimeUtc(packageIndexFile); 44File.SetLastWriteTimeUtc(packageIndexFile, originalModifiedTime); 61File.SetLastWriteTimeUtc(packageIndexFile, new DateTime(originalModifiedTime.Ticks + 100));
RuntimeGraphTests.cs (3)
20if (File.Exists(file)) 22File.Delete(file); 32File.Exists(file).Should().BeTrue();
Microsoft.DotNet.Build.Tasks.Templating (3)
GenerateFileFromTemplate.cs (3)
61if (!File.Exists(TemplateFile)) 68string template = File.ReadAllText(TemplateFile); 72File.WriteAllText(ResolvedOutputPath, result);
Microsoft.DotNet.Build.Tasks.Templating.Tests (4)
GenerateFileFromTemplateTests.cs (4)
27Assert.Equal(ReadAllText("Directory.Build.props.in").Replace("${DefaultNetCoreTargetFramework}", "net6.0"), File.ReadAllText(filePath)); 55Assert.Equal(ReadAllText("Directory.Build.props.in").Replace("${DefaultNetCoreTargetFramework}", string.Empty), File.ReadAllText(filePath)); 80Assert.Equal(ReadAllText(filename), File.ReadAllText(filePath)); 99return File.ReadAllText(path);
Microsoft.DotNet.Build.Tasks.VisualStudio (8)
OptProf\FindLatestDrop.cs (1)
41DropName = GetLatestDropName(File.ReadAllText(DropListPath));
OptProf\GenerateTrainingInputFiles.cs (4)
50config = OptProfTrainingConfiguration.Deserialize(File.ReadAllText(ConfigurationFile, Encoding.UTF8)); 99using (var archive = new ZipArchive(File.Open(vsixPath, FileMode.Open), ZipArchiveMode.Read)) 155while (File.Exists(fullPath)); 157using (var writer = new StreamWriter(File.Open(fullPath, FileMode.Create, FileAccess.Write, FileShare.Read)))
OptProf\GenerateTrainingPropsFile.cs (1)
55File.WriteAllText(outputFilePath,
OptProf\GetRunSettingsSessionConfiguration.cs (2)
55var buildDropName = GetTestsDropName(File.ReadAllText(BootstrapperInfoPath, Encoding.UTF8)); 56var (testContainersString, testCaseFilterString) = GetTestContainersAndFilters(File.ReadAllText(ConfigurationFile, Encoding.UTF8), ConfigurationFile);
Microsoft.DotNet.Build.Tasks.VisualStudio.Tests (9)
OptProf\GenerateTrainingInputFilesTests.cs (5)
141File.WriteAllText(configPath, s_optProfJson); 178var json = File.ReadAllText(Path.Combine(outputDir, @"DDRIT.RPS.CSharp\Configurations\DDRIT.RPS.CSharp.CSharpTest.BuildAndDebugging\System.Collections.Immutable.0.IBC.json")); 189json = File.ReadAllText(Path.Combine(outputDir, @"DDRIT.RPS.CSharp\Configurations\DDRIT.RPS.CSharp.CSharpTest.BuildAndDebugging\System.Collections.Immutable.1.IBC.json")); 200json = File.ReadAllText(Path.Combine(outputDir, @"DDRIT.RPS.CSharp\Configurations\DDRIT.RPS.CSharp.CSharpTest.EditingAndDesigner\xyzMicrosoft.CodeAnalysis.CSharp.0.IBC.json")); 210json = File.ReadAllText(Path.Combine(outputDir, @"TeamEng\Configurations\TeamEng.OptProfTest.vs_debugger_start_no_build_cs_scribble\xyzMicrosoft.CodeAnalysis.VisualBasic.0.IBC.json"));
OptProf\GenerateTrainingPropsFileTests.cs (2)
27var actual = File.ReadAllText(Path.Combine(dir, "dotnet.roslyn.props")); 55var actual = File.ReadAllText(Path.Combine(dir, "ProfilingInputs.props"));
OptProf\GetRunSettingsSessionConfigurationTests.cs (2)
420File.WriteAllText(configPath, products_only); 423File.WriteAllText(bootstrapperPath, @"[{""BuildDrop"": ""https://vsdrop.corp.microsoft.com/file/v1/Products/42.42.42.42/42.42.42.42""}]");
Microsoft.DotNet.Build.Tasks.Workloads (22)
CreateVisualStudioWorkload.wix.cs (1)
234if (!File.Exists(sourcePackage))
EmbeddedTemplates.cs (2)
42if (File.Exists(destinationPath)) 44File.Delete(destinationPath);
Msi\MsiBase.wix.cs (1)
156File.WriteAllText(eulaRtf, s_eula.Replace(__LICENSE_URL__, Metadata.LicenseUrl));
Msi\MsiProperties.wix.cs (1)
116File.WriteAllText(msiJsonPath, JsonSerializer.Serialize(properties));
Msi\WorkloadManifestMsi.wix.cs (1)
84File.WriteAllText(jsonFullPath, jsonAsString);
Swix\ComponentSwixProject.cs (1)
65using StreamWriter swrWriter = File.AppendText(componentSwr);
Swix\MsiSwixProject.wix.cs (1)
115using StreamWriter msiWriter = File.CreateText(Path.Combine(ProjectSourceDirectory, "msi.swr"));
Swix\PackageGroupSwixProject.wix.cs (1)
59using StreamWriter swrWriter = File.AppendText(packageGroupSwr);
Utils.cs (7)
68FileAttributes oldAttributes = File.GetAttributes(fileName); 69File.SetAttributes(fileName, oldAttributes & ~FileAttributes.ReadOnly); 71string content = File.ReadAllText(fileName); 78File.WriteAllText(fileName, content, encoding); 79File.SetAttributes(fileName, oldAttributes); 198if (File.Exists(path)) 200File.Delete(path);
WorkloadManifestPackage.wix.cs (3)
115return File.Exists(primaryManifest) ? primaryManifest : 116File.Exists(secondaryManifest) ? secondaryManifest : 128return WorkloadManifestReader.ReadWorkloadManifest(Path.GetFileNameWithoutExtension(workloadManifestFile), File.OpenRead(workloadManifestFile), workloadManifestFile);
WorkloadPackageBase.cs (2)
239File.Copy(PackagePath, Path.Combine(DestinationDirectory, Path.GetFileName(PackagePath)), overwrite: true); 261File.Delete(file);
WorkloadSetPackage.wix.cs (1)
121File.Delete(file);
Microsoft.DotNet.Build.Tasks.Workloads.Tests (22)
CreateVisualStudioWorkloadSetTests.cs (2)
71string msiSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(workloadSetSwixItem.ItemSpec), "msi.swr")); 82string packageGroupSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(workloadSetPackageGroupSwixItem.ItemSpec), "packageGroup.swr"));
CreateVisualStudioWorkloadTests.cs (6)
94string componentSwr = File.ReadAllText( 99string previewComponentSwr = File.ReadAllText( 128string manifestMsiSwr = File.ReadAllText(Path.Combine(baseIntermediateOutputPath, "src", "swix", "6.0.200", "Emscripten.Manifest-6.0.200", "x64", "msi.swr")); 144string packMsiSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(pythonPackSwixItem.ItemSpec), "msi.swr")); 229string componentSwr = File.ReadAllText( 250string manifestMsiSwr = File.ReadAllText(Path.Combine(baseIntermediateOutputPath, "src", "swix", "6.0.200", "Emscripten.Manifest-6.0.200", "arm64", "msi.swr"));
SwixComponentTests.cs (12)
31string componentSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.swr")); 35string componentResSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.res.swr")); 60string componentSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.swr")); 65string componentResSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.res.swr")); 89string componentSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.swr")); 94string componentResSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.res.swr")); 115string componentSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.swr")); 129string componentSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.swr")); 158string componentResSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.res.swr")); 174string componentSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.swr")); 189string componentSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "component.swr")); 199File.OpenRead(Path.Combine(TestAssetsPath, filename)), filename);
SwixPackageGroupTests.cs (1)
37string packageGroupSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(packageGroupItem.ItemSpec), "packageGroup.swr"));
SwixPackageTests.cs (1)
62string msiSwr = File.ReadAllText(Path.Combine(Path.GetDirectoryName(swixProj), "msi.swr"));
Microsoft.DotNet.Deployment.Tasks.Links (1)
Microsoft.DotNet.GenAPI (3)
GenAPITask.cs (3)
266return File.ReadAllText(headerFile); 290return File.CreateText(Path.Combine(outFilePath, filename)); 293return File.CreateText(outFilePath);
Microsoft.DotNet.GenFacades (9)
ClearAssemblyReferenceVersions.cs (1)
30using (FileStream stream = File.Open(Assembly, FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
NotSupportedAssemblyGenerator.cs (5)
47if (!string.IsNullOrEmpty(ApiExclusionListPath) && File.Exists(ApiExclusionListPath)) 49apiExclusions = File.ReadAllLines(ApiExclusionListPath); 57if (!File.Exists(sourceFile)) 79syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile), new CSharpParseOptions(languageVersion)); 90File.WriteAllText(outputPath, text);
SourceGenerator.cs (1)
91File.WriteAllText(_outputSourcePath, BuildAliasDeclarations(externAliases) + sb.ToString());
TypeParser.cs (2)
143if (!File.Exists(sourceFile)) 147SyntaxTree tree = CSharpSyntaxTree.ParseText(File.ReadAllText(sourceFile), options);
Microsoft.DotNet.Helix.JobSender (6)
Payloads\AdhocPayload.cs (1)
40using (FileStream inputStream = File.OpenRead(file))
Payloads\ArchivePayload.cs (3)
40return File.ReadAllText(alreadyUploadedFile.FullName); 43using (var stream = File.OpenRead(Archive.FullName)) 46File.WriteAllText(alreadyUploadedFile.FullName, zipUri.AbsoluteUri);
Payloads\DirectoryPayload.cs (2)
50return File.ReadAllText(alreadyUploadedFile.FullName); 75File.WriteAllText(alreadyUploadedFile.FullName, zipUri.AbsoluteUri);
Microsoft.DotNet.Helix.JobSender.Tests (1)
Payloads\ArchivePayloadTests.cs (1)
26await File.WriteAllBytesAsync(archiveFile, new byte[] { 1, 2, 3 });
Microsoft.DotNet.Helix.Sdk (3)
CommandPayload.cs (1)
58File.WriteAllText(scriptFile.FullName, contents.ToString(), s_utf8NoBom);
DownloadFromResultsContainer.cs (1)
53using (FileStream stream = File.Open(Path.Combine(directory.FullName, MetadataFile), FileMode.Create, FileAccess.Write))
SendHelixJob.cs (1)
528if (File.Exists(path))
Microsoft.DotNet.Helix.Sdk.Tests (3)
HelpersTests.cs (3)
57bool exists = File.Exists(target); 60File.WriteAllText(target, "Test failed once"); 61exists = File.Exists(target);
Microsoft.DotNet.Internal.SymbolHelper (9)
SymbolUploadHelper.cs (8)
65Debug.Assert(!string.IsNullOrEmpty(symbolToolPath) && (File.Exists(symbolToolPath) || options.IsDryRun)); 295using FileStream entryFile = File.Create(entryPath); 360using Stream pdbStream = File.OpenRead(file); 370if (!File.Exists(pePath)) 375if (!File.Exists(pePath)) 385using Stream peStream = File.OpenRead(pePath); 386using Stream convertedPdbStream = File.Create(convertedPdbPath); 404while (Directory.Exists(tempDir) || File.Exists(tempDir))
SymbolUploadHelperFactory.cs (1)
77if (!options.IsDryRun && !File.Exists(expectedSymbolPath))
Microsoft.DotNet.MacOsPkg.Core (9)
AppBundle.cs (1)
29File.Exists(Path.Combine(path, "Contents", "Info.plist"));
MacOsPkgCore.cs (2)
20if (!File.Exists(srcPath) || !Utilities.IsPkg(srcPath) && !Utilities.IsAppBundle(srcPath)) 102if (!File.Exists(srcPath) || (!Utilities.IsPkg(srcPath) && !Utilities.IsAppBundle(srcPath)))
Package.cs (4)
68File.Move(tempDest, packageName); 112File.Move(tempDest, app); 151File.Delete(appZip); 190File.Delete(payloadFilePath);
Utilities.cs (2)
29else if (File.Exists(path)) 31File.Delete(path);
Microsoft.DotNet.MacOsPkg.Tests (4)
UnpackPackTests.cs (4)
183else if (File.Exists(path)) 185File.Delete(path); 204File.Exists(dstPath).Should().BeTrue(); 249.Select(f => (f.Substring(basePath.Length + 1), File.GetUnixFileMode(f)))
Microsoft.DotNet.NuGetRepack.Tasks (9)
src\NuGetVersionUpdater.cs (3)
117File.Copy(packagePath, tempPathOpt); 255File.Delete(tempPathOpt); 374File.Copy(package.TempPathOpt, finalPath, overwrite: true);
src\ReplacePackageParts.cs (5)
126File.Copy(SourcePackage, tempPackagePath); 194replacementStream = File.OpenRead(replacementFilePath); 232using (var archive = new ZipArchive(File.Open(tempPackagePath, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update)) 240File.Copy(tempPackagePath, NewPackage, overwrite: true); 244File.Delete(tempPackagePath);
src\UpdatePackageVersionTask.cs (1)
91File.WriteAllLines(Path.Combine(OutputDirectory, "PreReleaseDependencies.txt"), preReleaseDependencies.Distinct());
Microsoft.DotNet.NuGetRepack.Tests (29)
ReplacePackagePartsTests.cs (3)
22File.WriteAllBytes(originalNupkgPath = Path.Combine(dir, TestResources.MiscPackages.NameSigned), TestResources.MiscPackages.Signed); 25File.WriteAllText(replacementFilePath = Path.Combine(dir, "Replacement.txt"), "<replacement>"); 43using (var archive = new ZipArchive(File.Open(task.NewPackage, FileMode.Open, FileAccess.Read), ZipArchiveMode.Read))
VersionUpdaterTests.cs (26)
63File.WriteAllBytes(a_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameA), TestResources.DailyBuildPackages.TestPackageA); 64File.WriteAllBytes(b_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameB), TestResources.DailyBuildPackages.TestPackageB); 65File.WriteAllBytes(c_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameC), TestResources.DailyBuildPackages.TestPackageC); 66File.WriteAllBytes(d_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameD), TestResources.DailyBuildPackages.TestPackageD); 67File.WriteAllBytes(g_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameG), TestResources.DailyBuildPackages.TestPackageG); 84AssertPackagesEqual(TestResources.ReleasePackages.TestPackageA, File.ReadAllBytes(a_rel)); 85AssertPackagesEqual(TestResources.ReleasePackages.TestPackageB, File.ReadAllBytes(b_rel)); 86AssertPackagesEqual(TestResources.ReleasePackages.TestPackageC, File.ReadAllBytes(c_rel)); 87AssertPackagesEqual(TestResources.ReleasePackages.TestPackageD, File.ReadAllBytes(d_rel)); 88AssertPackagesEqual(TestResources.ReleasePackages.TestPackageG, File.ReadAllBytes(g_rel)); 90AssertPackagesEqual(TestResources.PreReleasePackages.TestPackageA, File.ReadAllBytes(a_pre)); 91AssertPackagesEqual(TestResources.PreReleasePackages.TestPackageB, File.ReadAllBytes(b_pre)); 92AssertPackagesEqual(TestResources.PreReleasePackages.TestPackageC, File.ReadAllBytes(c_pre)); 93AssertPackagesEqual(TestResources.PreReleasePackages.TestPackageD, File.ReadAllBytes(d_pre)); 94AssertPackagesEqual(TestResources.PreReleasePackages.TestPackageG, File.ReadAllBytes(g_pre)); 106File.WriteAllBytes(e_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameE), TestResources.DailyBuildPackages.TestPackageE); 107File.WriteAllBytes(f_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameF), TestResources.DailyBuildPackages.TestPackageF); 118AssertPackagesEqual(TestResources.ReleasePackages.TestPackageE, File.ReadAllBytes(e_rel)); 119AssertPackagesEqual(TestResources.ReleasePackages.TestPackageF, File.ReadAllBytes(f_rel)); 121AssertPackagesEqual(TestResources.PreReleasePackages.TestPackageE, File.ReadAllBytes(e_pre)); 122AssertPackagesEqual(TestResources.PreReleasePackages.TestPackageF, File.ReadAllBytes(f_pre)); 134File.WriteAllBytes(a_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameA), TestResources.DailyBuildPackages.TestPackageA); 135File.WriteAllBytes(b_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameB), TestResources.DailyBuildPackages.TestPackageB); 136File.WriteAllBytes(c_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameC), TestResources.DailyBuildPackages.TestPackageC); 174File.WriteAllBytes(dotnet_tool = Path.Combine(dir, TestResources.MiscPackages.NameDotnetTool), TestResources.MiscPackages.DotnetTool); 176File.WriteAllBytes(normal_package_b_daily = Path.Combine(dir, TestResources.DailyBuildPackages.NameB), TestResources.DailyBuildPackages.TestPackageB);
Microsoft.DotNet.Open.Api.Tools.Tests (27)
OpenApiAddURLTests.cs (12)
39Assert.True(File.Exists(jsonFile)); 72Assert.True(File.Exists(jsonFile)); 105Assert.True(File.Exists(jsonFile)); 138Assert.True(File.Exists(jsonFile)); 170Assert.True(File.Exists(jsonFile)); 203Assert.True(File.Exists(firstJsonFile)); 231Assert.True(File.Exists(secondJsonFile)); 263Assert.True(File.Exists(resultFile)); 295Assert.True(File.Exists(resultFile)); 327Assert.True(File.Exists(resultFile)); 361Assert.True(File.Exists(resultFile)); 446Assert.False(File.Exists(jsonFile));
OpenApiRefreshTests.cs (11)
26await File.WriteAllTextAsync(expectedJsonPath, "trash"); 28var firstWriteTime = File.GetLastWriteTime(expectedJsonPath); 37var secondWriteTime = File.GetLastWriteTime(expectedJsonPath); 39Assert.Equal(Content, await File.ReadAllTextAsync(expectedJsonPath), ignoreLineEndingDifferences: true); 56await File.WriteAllTextAsync(expectedJsonPath, PackageUrlContent); 58var firstWriteTime = File.GetLastWriteTime(expectedJsonPath); 67var secondWriteTime = File.GetLastWriteTime(expectedJsonPath); 69Assert.Equal(Content, await File.ReadAllTextAsync(expectedJsonPath), ignoreLineEndingDifferences: true); 84var firstWriteTime = File.GetLastWriteTime(expectedJsonPath); 93var secondWriteTime = File.GetLastWriteTime(expectedJsonPath); 95Assert.Equal(Content, await File.ReadAllTextAsync(expectedJsonPath));
OpenApiRemoveTests.cs (2)
56Assert.False(File.Exists(Path.Combine(_tempDir.Root, nswagJsonFile))); 186Assert.False(File.Exists(Path.Combine(_tempDir.Root, nswagJsonFile)));
src\Tools\Shared\TestHelpers\TemporaryDirectory.cs (2)
59using (var stream = File.OpenRead(Path.Combine("TestContent", $"{name}.txt"))) 98File.WriteAllText(Path.Combine(Root, filename), contents);
Microsoft.DotNet.PackageTesting (1)
VerifyClosure.cs (1)
390using (var file = File.Create(dependencyGraphFilePath))
Microsoft.DotNet.RemoteExecutor (12)
MiniDump.cs (1)
25using (FileStream fs = File.Create(destinationPath))
Program.cs (1)
95File.WriteAllText(exceptionFile, output.ToString());
RemoteExecutor.cs (7)
77if (File.Exists(dotnetExe)) 468File.WriteAllText(options.ExceptionFile, ""); 535File.Copy(RuntimeConfigPath, configFile); 553File.WriteAllText(devConfigFile, devConfigFileContents); 580File.Delete(file); 651.Where(File.Exists) 656.Where(File.Exists)
RemoteInvokeHandle.cs (3)
232throw new RemoteExecutionException("Remote process failed with an unhandled exception.", File.ReadAllText(Options.ExceptionFile)); 248if (File.Exists(Options.ExceptionFile)) 250File.Delete(Options.ExceptionFile);
Microsoft.DotNet.SetupNugetSources.Tests (41)
BoundaryConditionTests.cs (10)
45await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 56var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 73await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 83var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 102await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 108var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 142await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 151var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 171await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 177var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
CredentialHandlingTests.cs (10)
49await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 56var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 87await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 94var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 129await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 136var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 161await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 168var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 199await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 206var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
FeedEnablingTests.cs (10)
54await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 60var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 94await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 101var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 128await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 135var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 161await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 168var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 194await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 201var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
InternalFeedAdditionTests.cs (6)
55await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 61var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 88await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 94var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 125await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 131var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
NoChangeScenarioTests.cs (4)
50await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 57var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath)); 74await Task.Run(() => File.WriteAllText(configPath, originalConfig)); 80var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
SetupNugetSourcesFixture.cs (1)
46File.Copy(file, destPath, overwrite: true);
Microsoft.DotNet.SharedFramework.Sdk (7)
src\CreateFrameworkListFile.cs (1)
261File.WriteAllText(TargetFile, frameworkManifest.ToString());
src\FileUtilities.cs (1)
41using (var stream = File.OpenRead(path))
src\GenerateSharedFrameworkDepsFile.cs (3)
118using var depsStream = File.Create(depsFilePath); 125if (File.Exists(depsFilePath)) 127File.Delete(depsFilePath);
src\Microsoft.DotNet.PackageTesting\VerifyClosure.cs (1)
390using (var file = File.Create(dependencyGraphFilePath))
src\ValidateFileVersions.cs (1)
96if (File.Exists(filePath))
Microsoft.DotNet.SignCheckLibrary (18)
Interop\PortableExecutable\ImageCor20Header.cs (1)
53using (FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
Logging\FileLogger.cs (2)
45MessageWriter = File.CreateText(messageFile); 54ErrorWriter = File.CreateText(errorFile);
Utils.cs (1)
212using (FileStream fileStream = File.Create(keyPath))
Verification\ArchiveVerifier.cs (1)
104if (File.Exists(aliasFullName))
Verification\DebVerifier.cs (2)
42=> File.WriteAllBytes(targetPath, ((MemoryStream)archiveEntry.ContentStream).ToArray()); 49using var archive = new ArReader(File.OpenRead(archivePath), leaveOpen: false);
Verification\Exclusions.cs (2)
45if (File.Exists(path)) 47using (StreamReader fileReader = File.OpenText(path))
Verification\JavaScriptVerifier.cs (1)
25string content = File.ReadAllText(path);
Verification\PkgVerifier.cs (1)
48using var stream = (Stream)File.Open(path, FileMode.Open);
Verification\RpmVerifier.cs (5)
25using var stream = File.Open(archivePath, FileMode.Open); 27using var dataStream = File.Create(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); 46using var rpmPackageStream = File.Open(archivePath, FileMode.Open); 55File.WriteAllBytes(signatureDocument, [.. (ArraySegment<byte>)pgpEntry]); 58using (var signableContentStream = File.Create(signableContent))
Verification\TarVerifier.cs (1)
28using (var fileStream = File.Open(archivePath, FileMode.Open))
Verification\ZipVerifier.cs (1)
23using (var archive = new ZipArchive(File.OpenRead(archivePath), ZipArchiveMode.Read, leaveOpen: false))
Microsoft.DotNet.SignCheckTask (3)
src\SignCheck.cs (3)
271else if (File.Exists(Path.GetFullPath(inputFile))) 479if (File.Exists(downloadPath)) 482File.Delete(downloadPath);
Microsoft.DotNet.SignTool (53)
src\BatchSignUtil.cs (4)
215File.Delete(engine.Key.FileName); 453File.Copy(src, dst, overwrite: true); 610if (!File.Exists(sigFilePath)) 629using (var stream = File.OpenRead(file.FullPath))
src\Configuration.cs (1)
705using (var stream = File.OpenRead(filePath))
src\ContentUtil.cs (1)
31using (var stream = File.OpenRead(fullPath))
src\RealSignTool.cs (2)
99File.WriteAllText(logPath, outputStr); 105File.WriteAllText(errorLogPath, errorStr);
src\SignTool.cs (9)
139File.Delete(item.Value); 161File.WriteAllText(signProjectPath, GenerateBuildFileContent(filesToSign, zippedPaths, false)); 178if (File.Exists(backupPath)) 180File.Delete(backupPath); 193File.WriteAllText(notarizeProjectPath, GenerateBuildFileContent(filesToNotarize, null, true)); 211File.Copy(fileInfo.FullPath, fileInfo.DetachedSignatureFullPath); 216File.Copy(backupPath, fileInfo.FullPath, overwrite: true); 236File.Copy(fileInfo.FullPath, backupPath); 296if (File.Exists(zipFilePath))
src\SignToolTask.cs (1)
218if (!File.Exists(DotNetPath))
src\VerifySignatures.cs (7)
95using var rpmPackageStream = File.Open(filePath, FileMode.Open); 104File.WriteAllBytes(pgpSignableContent, [.. (ArraySegment<byte>)pgpEntry]); 108using (var signableContentStream = File.Create(signableContent)) 130return File.ReadLines(filePath).Any(line => line.IndexOf("# SIG # Begin Signature Block", StringComparison.OrdinalIgnoreCase) >= 0) 137using (BinaryReader binaryReader = new BinaryReader(File.OpenRead(filePath))) 172using var archive = new ZipArchive(File.OpenRead(filePath), ZipArchiveMode.Read, leaveOpen: false); 275using (FileStream fileStream = File.Create(keyPath))
src\ZipData.cs (27)
198using (var archive = new ZipArchive(File.OpenRead(archivePath), ZipArchiveMode.Read, leaveOpen: false)) 212using (var zipStream = File.Open(FileSignInfo.FullPath, FileMode.Open)) 225using (var signedStream = File.OpenRead(signedPart.Value.FileSignInfo.FullPath)) 269File.Copy(signedPart.Value.FileSignInfo.FullPath, file, true); 272string wixPath = File.ReadAllText(createFileName).Contains("light.exe") 282if (!File.Exists(outputFileName)) 289File.Copy(outputFileName, FileSignInfo.FullPath, true); 338using var stream = ignoreContent ? null : (Stream)File.Open(path, FileMode.Open); 385UnixFileMode extractedFileMode = File.GetUnixFileMode(path); 388File.Copy(signedPart.Value.FileSignInfo.FullPath, path, overwrite: true); 389File.SetUnixFileMode(path, extractedFileMode); 500using FileStream signedStream = File.OpenRead(signedPart.Value.FileSignInfo.FullPath); 516using (FileStream outputStream = File.Open(FileSignInfo.FullPath, FileMode.Truncate, FileAccess.Write)) 525using FileStream streamToDecompress = File.OpenRead(path); 608File.Copy(sumsFile, Path.Combine(controlLayout, "md5sums"), overwrite: true); 612string fileContents = File.ReadAllText(controlFile); 619File.WriteAllText(controlFile, fileContents); 633using FileStream fileStream = File.OpenRead(Path.Combine(controlLayout, relativeName)); 645using (FileStream outputStream = File.Open(controlArchive, FileMode.Create)) 667using (FileStream outputFileStream = File.Create(outputPath)) 677using var archive = new ArReader(File.OpenRead(archivePath), leaveOpen: false); 702using var stream = File.Open(archivePath, FileMode.Open); 727File.Copy(signedPart.FileSignInfo.FullPath, Path.Combine(layout, signedPart.RelativeName), overwrite: true); 756File.WriteAllText(file, contents); 793using var stream = File.Open(rpmPackage, FileMode.Open); 853File.SetUnixFileMode(outputPath, (UnixFileMode)mode); 861return OperatingSystem.IsWindows() ? null : (uint)File.GetUnixFileMode(filePath);
src\ZipDataEntry.cs (1)
73using var fs = File.Create(path);
Microsoft.DotNet.SignTool.Tests (22)
FakeSignTool.cs (1)
53using (var stream = File.OpenWrite(Uri.UnescapeDataString(path)))
SignToolTests.cs (21)
299if (!File.Exists(dstPath)) 301File.Copy(srcPath, dstPath); 311File.WriteAllText(dstPath, "This is a test file content"); 429string md5sumsContents = File.ReadAllText(Path.Combine(controlLayout, "md5sums")); 439File.Exists(layoutFilePath).Should().BeTrue(); 442using FileStream fileStream = File.OpenRead(layoutFilePath); 459string controlFileContents = File.ReadAllText(Path.Combine(controlLayout, "control")); 493File.Exists(layoutFilePath).Should().BeTrue(); 496using FileStream fileStream = File.OpenRead(layoutFilePath); 516using var stream = File.Open(rpmPackage, FileMode.Open); 3078File.WriteAllBytes(unknownFile, new byte[] { 0x12, 0x34, 0x56, 0x78 }); 3084File.WriteAllBytes(emptyFile, new byte[0]); 3090File.WriteAllBytes(smallPeFile, new byte[] { 0x4D, 0x5A }); // Just the DOS header 3096File.WriteAllBytes(incompletePeFile, new byte[] { 0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00 }); // DOS header with no PE header 3246File.Delete(Path.Combine(workingDir, "bundle.wxs")); 3250File.Exists(outputFileName).Should().Be(!deleteWxsBeforeRunningTool); 3358using var inputStream = File.OpenRead(GetResourcePath("SignedLibrary.dll")); 3372using var inputStream = File.OpenRead(GetResourcePath("SignedLibrary.dll")); 3387using var inputStream = File.OpenRead(GetResourcePath("InvalidatedStrongName.dll")); 3449using (var inputStream = File.OpenRead(GetResourcePath("StrongNamedWithEcmaKey.dll"))) 3460using (var inputStream = File.OpenRead(GetResourcePath("DelaySigned.dll")))
Microsoft.DotNet.SourceBuild.Tasks (13)
src\UsageReport\WritePackageUsageData.cs (5)
153File.Open( 163using (var stream = File.OpenRead(Path.Combine(RootDir, relativePath))) 184using (var file = File.OpenRead(Path.Combine(RootDir, assetFile))) 255File.WriteAllText(DataFile, data.ToXml().ToString()); 276var root = JObject.Parse(File.ReadAllText(path));
src\UsageReport\WriteUsageReports.cs (7)
63UsageData data = UsageData.Parse(XElement.Parse(File.ReadAllText(DataFile))); 79if (File.Exists(ProdConBuildManifestFile)) 81var xml = XElement.Parse(File.ReadAllText(ProdConBuildManifestFile)); 93if (File.Exists(PoisonedReportFile)) 95foreach (string line in File.ReadAllLines(PoisonedReportFile)) 161File.WriteAllText( 173var content = File.ReadAllText(item.ItemSpec);
src\WriteBuildOutputProps.cs (1)
77using (var outStream = File.Open(OutputPath, FileMode.Create))
Microsoft.DotNet.StrongName (1)
Signing.cs (1)
168if (!TryParseKey(File.ReadAllBytes(keyFile).ToImmutableArray(), out ImmutableArray<byte> snkPublicKey, out RSAParameters? privateKey) ||
Microsoft.DotNet.SwaggerGenerator.CmdLine (1)
Program.cs (1)
110File.WriteAllText(file.FullName, contents);
Microsoft.DotNet.SwaggerGenerator.MSBuild (1)
GenerateSwaggerCode.cs (1)
89File.WriteAllText(file.FullName, contents);
Microsoft.DotNet.Tar (3)
Program.cs (3)
24if (File.Exists(srcPath)) 28using var srcStream = File.Open(srcPath, FileMode.Open); 35using var dstStream = File.Open(dstPath, FileMode.Create);
Microsoft.DotNet.VersionTools.Cli (1)
FileSystemProxy.cs (1)
25File.Move(sourceFileName, destFileName);
Microsoft.DotNet.XliffTasks (10)
Model\Document.cs (5)
31using FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); 72using (FileStream stream = File.Open(tempPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) 79if (File.Exists(path)) 81File.Replace( 89File.Move(sourceFileName: tempPath, destFileName: path);
Tasks\TransformTemplates.cs (4)
74File.Copy(templatePath, cultureSpecificTemplateFile, overwrite: true); 80File.Copy(projectFileFullPath, Path.Combine(localizedTemplateDirectory, Path.GetFileName(projectNode.Attribute("File").Value)), overwrite: true); 108File.Copy(Path.Combine(TranslatedOutputDirectory, localizedFileName), templateItemDestinationPath, overwrite: true); 113File.Copy(templateItemFullPath, templateItemDestinationPath, overwrite: true);
Tasks\XlfTask.cs (1)
73if (File.Exists(path))
Microsoft.Extensions.AI.Evaluation.Console (5)
Telemetry\DeviceIdHelper.cs (3)
92if (File.Exists(cacheFilePath)) 94_deviceId = File.ReadAllText(cacheFilePath); 124File.WriteAllText(cacheFilePath, deviceId);
Telemetry\TelemetryConstants.cs (2)
112_firstUseSentinelFileExists = File.Exists(_firstUseSentinelFilePath); 167await File.WriteAllBytesAsync(_firstUseSentinelFilePath, []).ConfigureAwait(false);
Microsoft.Extensions.AI.Evaluation.Reporting (10)
Storage\DiskBasedResponseCache.CacheEntry.cs (4)
33using FileStream cacheEntryFile = File.OpenRead(cacheEntryFilePath); 49using FileStream cacheEntryFile = File.OpenRead(cacheEntryFilePath); 64using FileStream cacheEntryFile = File.Create(cacheEntryFilePath); 72using FileStream cacheEntryFile = File.Create(cacheEntryFilePath);
Storage\DiskBasedResponseCache.cs (6)
67return File.ReadAllBytes(contentsFilePath); 89return await File.ReadAllBytesAsync(contentsFilePath, cancellationToken).ConfigureAwait(false); 195File.WriteAllBytes(contentsFilePath, value); 212await File.WriteAllBytesAsync(contentsFilePath, value, cancellationToken).ConfigureAwait(false); 296bool contentsFileExists = File.Exists(contentsFilePath); 297bool entryFileExists = File.Exists(entryFilePath);
Microsoft.Extensions.AI.Templates.Tests (5)
test\ProjectTemplates\Infrastructure\TemplateExecutionTestClassFixtureBase.cs (2)
56File.Copy(WellKnownPaths.TemplateInstallNuGetConfigPath, installNuGetConfigPath); 92File.Copy(WellKnownPaths.TemplateTestNuGetConfigPath, templateNuGetConfigPath);
test\ProjectTemplates\Infrastructure\TemplateExecutionTestCollectionFixture.cs (1)
36File.Copy(filePath, destFilePath);
test\ProjectTemplates\Infrastructure\WellKnownPaths.cs (2)
53if (Directory.Exists(gitPath) || File.Exists(gitPath)) 74if (!File.Exists(dotNetExePath))
Microsoft.Extensions.ApiDescription.Client.Tests (3)
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\Tools\Shared\TestHelpers\TemporaryDirectory.cs (2)
59using (var stream = File.OpenRead(Path.Combine("TestContent", $"{name}.txt"))) 98File.WriteAllText(Path.Combine(Root, filename), contents);
Microsoft.Extensions.ApiDescription.Tool.Tests (20)
GetDocumentTests.cs (18)
39using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample.json"))); 66using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample.json"))); 93using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample.json"))); 126using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample_internal.json"))); 154Assert.False(File.Exists(Path.Combine(outputPath.FullName, "Sample.json"))); 155Assert.False(File.Exists(Path.Combine(outputPath.FullName, "Sample_internal.json"))); 156Assert.False(File.Exists(Path.Combine(outputPath.FullName, "Sample_invalid.json"))); 182Assert.True(File.Exists(Path.Combine(outputPath.FullName, $"{fileName}.json"))); 183Assert.True(File.Exists(Path.Combine(outputPath.FullName, $"{fileName}_internal.json"))); 184Assert.False(File.Exists(Path.Combine(outputPath.FullName, "Sample.json"))); 185Assert.False(File.Exists(Path.Combine(outputPath.FullName, "Sample_internal.json"))); 211Assert.False(File.Exists(Path.Combine(outputPath.FullName, $"{fileName}.json"))); 212Assert.False(File.Exists(Path.Combine(outputPath.FullName, "Sample.json"))); 213Assert.False(File.Exists(Path.Combine(outputPath.FullName, "Sample_internal.json"))); 235Assert.False(File.Exists(Path.Combine(outputPath.FullName, ".json"))); 236Assert.False(File.Exists(Path.Combine(outputPath.FullName, "_internal.json"))); 237Assert.True(File.Exists(Path.Combine(outputPath.FullName, "Sample.json"))); 238Assert.True(File.Exists(Path.Combine(outputPath.FullName, "Sample_internal.json")));
src\Tools\Shared\TestHelpers\TemporaryDirectory.cs (2)
59using (var stream = File.OpenRead(Path.Combine("TestContent", $"{name}.txt"))) 98File.WriteAllText(Path.Combine(Root, filename), contents);
Microsoft.Extensions.Caching.StackExchangeRedis.Tests (4)
Infrastructure\RedisTestConfig.cs (4)
114if (!File.Exists(serverPath)) 117if (!File.Exists(serverPath)) 158if (!File.Exists(tempRedisServerFullPath)) 160File.Copy(serverExePath, tempRedisServerFullPath);
Microsoft.Extensions.DataIngestion.Markdig (1)
MarkdownReader.cs (1)
23string fileContent = await File.ReadAllTextAsync(source.FullName, cancellationToken).ConfigureAwait(false);
Microsoft.Extensions.DataIngestion.MarkItDown (2)
MarkItDownMcpReader.cs (1)
48ReadOnlyMemory<byte> fileBytes = await File.ReadAllBytesAsync(source.FullName, cancellationToken).ConfigureAwait(false);
MarkItDownReader.cs (1)
130File.Delete(inputFilePath);
Microsoft.Extensions.DataIngestion.Tests (5)
IngestionPipelineTests.cs (2)
53File.WriteAllText(_withTable.FullName, FirstFileContent); 69File.WriteAllText(_withImage.FullName, secondFileContent);
Readers\DocumentReaderConformanceTests.cs (2)
51await File.WriteAllTextAsync(filePath, "This is a test file for cancellation token."); 66File.Delete(filePath);
Writers\SqliteVectorStoreWriterTests.cs (1)
15public void Dispose() => File.Delete(_tempFile);
Microsoft.Extensions.DependencyModel (4)
FileWrapper.cs (4)
14return File.Exists(path); 19return File.ReadAllText(path); 24return File.OpenRead(path); 42File.Create(path).Dispose();
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (9)
Linux\Resources\FileNamesOnlyFileSystem.cs (4)
33var a = File.ReadAllLines($"{_directory}/{file.Name}") 41var c = File.ReadAllText($"{_directory}/{file.Name}"); 48var c = File.ReadAllText($"{_directory}/{file.Name}"); 61string[] lines = File.ReadAllLines($"{_directory}/{file.Name}");
Linux\Resources\TestResources.cs (5)
58if (!File.Exists(files.Key)) 62File.Create(files.Key).Close(); 67using var sw = File.CreateText(files.Key); 80if (File.Exists(d)) 82File.Delete(d);
Microsoft.Extensions.FileProviders.Embedded (2)
EmbeddedFileProvider.cs (1)
63_lastModified = File.GetLastWriteTimeUtc(assemblyLocation);
ManifestEmbeddedFileProvider.cs (1)
135result = File.GetLastWriteTimeUtc(assemblyLocation);
Microsoft.Extensions.FileProviders.Physical (1)
PollingWildCardChangeToken.cs (1)
172return FileSystemInfoHelper.GetFileLinkTargetLastWriteTimeUtc(filePath) ?? File.GetLastWriteTimeUtc(filePath);
Microsoft.Extensions.Hosting.Systemd (1)
SystemdHelpers.cs (1)
57byte[] comm = File.ReadAllBytes("/proc/" + ppidString + "/comm");
Microsoft.Extensions.Http.Diagnostics.PerformanceTests (2)
NoRemoteCallHandler.cs (1)
30var fileContent = File.ReadAllBytes(responseFilePath);
NoRemoteCallNotSeekableHandler.cs (1)
33var fileContent = File.ReadAllBytes(responseFilePath);
Microsoft.Extensions.Http.Diagnostics.Tests (1)
Logging\Internal\NoRemoteCallHandler.cs (1)
26_fileContent = File.ReadAllBytes(responseFilePath);
Microsoft.Extensions.Logging.AzureAppServices (1)
FileLoggerProvider.cs (1)
52using (var streamWriter = File.AppendText(fullName))
Microsoft.Extensions.ML (1)
ModelLoaders\FileModelLoader.cs (1)
40if (!File.Exists(filePath))
Microsoft.Extensions.ML.Tests (1)
FileLoaderTests.cs (1)
74File.WriteAllText("testdata.txt", "test");
Microsoft.Extensions.SecretManager.Tools.Tests (10)
SecretManagerTests.cs (5)
245File.WriteAllText(secretsFile, @"{ ""AzureAd"": { ""ClientSecret"": ""abcd郩˙î""} }", Encoding.UTF8); 258File.WriteAllText(secretsFile, @"{ ""AzureAd"": { ""ClientSecret"": ""abcd郩˙î""} }", Encoding.UTF8); 274File.WriteAllText(secretsFile, @"{ ""AzureAd"": { ""ClientSecret"": ""abcd郩˙î""} }", Encoding.UTF8); 280var fileContents = File.ReadAllText(secretsFile, Encoding.UTF8); 379Assert.Equal(UnixFileMode.UserRead | UnixFileMode.UserWrite, File.GetUnixFileMode(secretManager.SecretsFilePath));
src\Tools\Shared\TestHelpers\TemporaryDirectory.cs (2)
59using (var stream = File.OpenRead(Path.Combine("TestContent", $"{name}.txt"))) 98File.WriteAllText(Path.Combine(Root, filename), contents);
TemporaryFileProvider.cs (1)
21File.WriteAllText(Path.Combine(Root, filename), contents, Encoding.UTF8);
UserSecretsTestFixture.cs (2)
68File.WriteAllText( 81File.WriteAllText(Path.Join(directory.FullName, "app.cs"), $"""
Microsoft.Extensions.ServiceDiscovery.Dns (6)
DnsSrvServiceEndpointProviderFactory.cs (6)
87if (File.Exists(s_serviceAccountNamespacePath)) 89return File.ReadAllText(s_serviceAccountNamespacePath).Trim(); 97if (!File.Exists(s_resolveConfPath)) 104var lines = File.ReadAllLines(s_resolveConfPath); 134if (!File.Exists(tokenPath)) 140return File.Exists(certPath);
Microsoft.Extensions.ServiceDiscovery.Dns.Tests.Fuzzing (1)
Program.cs (1)
61fuzzer.FuzzTarget(File.ReadAllBytes(inputFile));
Microsoft.Gen.ComplianceReports (1)
ComplianceReportsGenerator.cs (1)
112File.WriteAllText(Path.Combine(_directory, _fileName), report, Encoding.UTF8);
Microsoft.Gen.ComplianceReports.Unit.Tests (9)
GeneratorTests.cs (9)
65if (File.Exists(goldenReportFile)) 68var d = await RunGenerator(File.ReadAllText(inputFile), tmp, options); 71var golden = File.ReadAllText(goldenReportFile); 72var generated = File.ReadAllText(tmp); 86File.Delete(tmp); 93_ = await RunGenerator(File.ReadAllText(inputFile), goldenReportFile, options); 131var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options: options); 154var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options: options); 156Assert.True(File.Exists(Path.Combine(fullReportPath, "ComplianceReport.json")));
Microsoft.Gen.ContextualOptions.Unit.Tests (21)
EmitterTests.cs (7)
27.ParseCompilationUnit(File.ReadAllText("TestClasses/Struct1.cs")) 46.ParseCompilationUnit(File.ReadAllText("TestClasses/Class2A.cs")) 50.ParseCompilationUnit(File.ReadAllText("TestClasses/Class2B.cs")) 78.ParseCompilationUnit(File.ReadAllText("TestClasses/Record1.cs")) 106.ParseCompilationUnit(File.ReadAllText("TestClasses/NamespacelessRecord.cs")) 133sources.Add(File.ReadAllText(file)); 149var golden = File.ReadAllText($"GoldenFiles/Microsoft.Gen.ContextualOptions/Microsoft.Gen.ContextualOptions.ContextualOptionsGenerator/ContextualOptions.g.cs");
ParserTests.cs (5)
24File.ReadAllText("TestClasses/ClassWithUnusableProperties.txt"), 41File.ReadAllText("TestClasses/NamespacelessRecord.cs"), 58File.ReadAllText("TestClasses/NonPartialClass.txt"), 73File.ReadAllText("TestClasses/StaticClass.txt"), 88File.ReadAllText("TestClasses/RefStruct.txt"),
SyntaxContextReceiverTests.cs (9)
24File.ReadAllText("TestClasses/Class1.cs"), 25File.ReadAllText("TestClasses/Struct1.cs"), 26File.ReadAllText("TestClasses/Record1.cs"), 47File.ReadAllText("TestClasses/Class1.cs"), 48File.ReadAllText("TestClasses/Struct1.cs"), 49File.ReadAllText("TestClasses/Record1.cs"), 63File.ReadAllText("TestClasses/Class2A.cs"), 64File.ReadAllText("TestClasses/Class2B.cs"), 83var sources = new[] { File.ReadAllText("TestClasses/ClassWithNoAttribute.cs"), };
Microsoft.Gen.Logging.Unit.Tests (1)
EmitterTests.cs (1)
28sources.Add(File.ReadAllText(file));
Microsoft.Gen.MetadataExtractor (3)
MetadataReportsGenerator.cs (1)
110File.WriteAllText(Path.Combine(path, _fileName), reportStringBuilder.ToString(), Encoding.UTF8);
src\Generators\Microsoft.Gen.ComplianceReports\ComplianceReportsGenerator.cs (1)
112File.WriteAllText(Path.Combine(_directory, _fileName), report, Encoding.UTF8);
src\Generators\Microsoft.Gen.MetricsReports\MetricsReportsGenerator.cs (1)
86File.WriteAllText(Path.Combine(path, _fileName), report, Encoding.UTF8);
Microsoft.Gen.MetadataExtractor.Unit.Tests (11)
GeneratorTests.cs (11)
85if (File.Exists(goldenReportPath)) 87var d = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 90var golden = await File.ReadAllTextAsync(goldenReportPath); 91var generated = await File.ReadAllTextAsync(generatedReportPath); 105File.Delete(generatedReportPath); 113_ = await RunGenerator(await File.ReadAllTextAsync(inputFile), options, reportFileName: goldenFileName); 132var d = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 134Assert.False(File.Exists(Path.Combine(Path.GetTempPath(), ReportFilename))); 156var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 182var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 184Assert.True(File.Exists(Path.Combine(fullReportPath, ReportFilename)));
Microsoft.Gen.Metrics.Unit.Tests (3)
EmitterTests.cs (3)
26sources.Add(File.ReadAllText(file)); 46var goldenCache = File.ReadAllText($"{generatedContentPath}/Factory.g.cs"); 47var goldenMetrics = File.ReadAllText($"{generatedContentPath}/Metrics.g.cs");
Microsoft.Gen.MetricsReports (1)
MetricsReportsGenerator.cs (1)
86File.WriteAllText(Path.Combine(path, _fileName), report, Encoding.UTF8);
Microsoft.Gen.MetricsReports.Unit.Tests (11)
GeneratorTests.cs (11)
50if (File.Exists(goldenReportPath)) 52var d = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 55var golden = await File.ReadAllTextAsync(goldenReportPath); 56var generated = await File.ReadAllTextAsync(generatedReportPath); 70File.Delete(generatedReportPath); 77_ = await RunGenerator(await File.ReadAllTextAsync(inputFile), options, reportFileName: goldenFileName); 92var d = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 94Assert.False(File.Exists(Path.Combine(Path.GetTempPath(), ReportFilename))); 112var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 135var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options); 137Assert.True(File.Exists(Path.Combine(fullReportPath, ReportFilename)));
Microsoft.Maui (3)
Fonts\FileSystemEmbeddedFontLoader.cs (3)
57 if (File.Exists(filePath)) 68 using (var fileStream = File.Create(filePath)) 79 File.Delete(filePath);
Microsoft.Maui.Controls.Build.Tasks (1)
XamlCTask.cs (1)
164 if (!File.Exists(Assembly))
Microsoft.Maui.Resizetizer (22)
AndroidAdaptiveIconGenerator.cs (4)
148 if (File.Exists(adaptiveIconDestination) && File.Exists(adaptiveIconRoundDestination)) 159 File.WriteAllText(adaptiveIconDestination, adaptiveIconXmlStr); 160 File.WriteAllText(adaptiveIconRoundDestination, adaptiveIconXmlStr);
AppleIconAssetsGenerator.cs (1)
88 File.WriteAllText(appIconSetContentsFile, appIconContentsJson.Replace("\t", " "));
CreatePartialInfoPlistTask.cs (1)
36 using (var f = File.CreateText(plistFilename))
GenerateSplashStoryboard.cs (2)
92 using var writer = File.CreateText(storyboardFile); 103 using var writer = File.CreateText(storyboardFile);
Resizer.cs (1)
73 File.Copy(Info.Filename, destination, true);
ResizetizeImages.cs (1)
122 File.SetLastWriteTimeUtc(itemSpec, DateTime.UtcNow);
SkiaSharpAppIconTools.cs (3)
18 var hasBackground = !string.IsNullOrWhiteSpace(info.Filename) && File.Exists(info.Filename); 19 var hasForeground = !string.IsNullOrWhiteSpace(info.ForegroundFilename) && File.Exists(info.ForegroundFilename); 75 using var wrapper = File.Create(destination);
SkiaSharpTools.cs (1)
213 using var stream = File.Create(destination);
TizenSplashUpdater.cs (2)
44 if (File.Exists(destination)) 108 using var stream = File.Create(destFilePath);
Utils.cs (5)
56 var exists = File.Exists(path); 57 var modified = exists ? File.GetLastWriteTimeUtc(path) : System.DateTime.MinValue; 63 if (checkExists && !File.Exists(source)) 66 var attributes = File.GetAttributes(source); 68 File.SetAttributes(source, attributes & ~FileAttributes.ReadOnly);
WindowsIconGenerator.cs (1)
50 using BinaryWriter writer = new BinaryWriter(File.Create(destination));
Microsoft.ML.AutoML (2)
AutoMLExperiment\ITrialResultManager.cs (1)
130if (!File.Exists(filePath))
Experiment\ModelContainer.cs (1)
27using (var fs = File.Create(fileInfo.FullName))
Microsoft.ML.AutoML.Samples (3)
AutoFit\BinaryClassificationExperiment.cs (1)
44using (FileStream fs = File.Create(ModelPath))
AutoFit\MulticlassClassificationExperiment.cs (1)
45using (FileStream fs = File.Create(ModelPath))
AutoFit\RegressionExperiment.cs (1)
45using (FileStream fs = File.Create(ModelPath))
Microsoft.ML.AutoML.Tests (6)
DatasetUtil.cs (3)
205if (File.Exists(relativeFilePath)) 228if (File.Exists(Path.Combine(destFolder, flag))) 232File.Create(Path.Combine(destFolder, flag));
TrialResultManagerTest.cs (2)
80var fileContent = File.ReadAllText(tempFilePath); 85File.Delete(tempFilePath);
UserInputValidationTests.cs (1)
188File.Create(emptyFilePath).Dispose();
Microsoft.ML.CodeGenerator (1)
Utils.cs (1)
181File.WriteAllText($"{outPutBaseDir}/{fileName}", fileContent);
Microsoft.ML.Core (11)
ComponentModel\AssemblyLoadingUtils.cs (1)
34if (!File.Exists(path))
Data\IFileHandle.cs (1)
140File.Delete(_fullPath);
Data\Repository.cs (1)
409File.Delete(path);
Utilities\PathUtils.cs (2)
106if (File.Exists(candidate)) 115if (File.Exists(candidate))
Utilities\ResourceManagerUtils.cs (6)
111if (File.Exists(filePath) || !string.IsNullOrEmpty(error)) 169if (File.Exists(filePath)) 181File.Delete(filePath); 251if (File.Exists(path)) 256if (File.Exists(path)) 290File.Move(tempPath, path);
Microsoft.ML.Core.Tests (39)
UnitTests\FileSource.cs (6)
35File.WriteAllText(file1, "Unit Test"); 36File.WriteAllText(file2, "Unit Test"); 60File.WriteAllText(fileDataA, "Unit Test"); 61File.WriteAllText(fileDataB, "Unit Test"); 70File.WriteAllText(fileDataSA, "Unit Test"); 71File.WriteAllText(fileDataSB, "Unit Test");
UnitTests\TestEntryPoints.cs (26)
242File.WriteAllLines(epListPath, epListContents); 248using (var file = File.OpenWrite(manifestPath)) 269File.WriteAllLines(path, epListContents); 275using (var file = File.OpenWrite(jPath)) 610File.WriteAllLines(jsonPath, new[] { inputGraph }); 738File.WriteAllLines(jsonPath, new[] { inputGraph }); 886File.WriteAllLines(jsonPath, new[] { inputGraph }); 1047File.WriteAllLines(jsonPath, new[] { inputGraph }); 1190File.WriteAllLines(jsonPath, new[] { inputGraph }); 1337File.WriteAllLines(jsonPath, new[] { inputGraph }); 1434File.WriteAllLines(jsonPath, new[] { inputGraph }); 2231using (var file = File.OpenWrite(summaryPath)) 2241using (var file = File.OpenWrite(summaryKvpPath)) 2324File.WriteAllLines(jsonPath, new[] { inputGraph }); 2374File.WriteAllLines(jsonPath, new[] { inputGraph }); 2419File.WriteAllLines(jsonPath, new[] { inputGraph }); 2465File.WriteAllLines(jsonPath, new[] { inputGraph }); 2520File.WriteAllLines(jsonPath, new[] { inputGraph }); 2635File.WriteAllLines(jsonPath, new[] { inputGraph }); 2860File.WriteAllLines(dataFile, new[] { 3255File.WriteAllLines(jsonPath, new[] { inputGraph }); 3324File.WriteAllLines(jsonPath, new[] { inputGraph }); 4412File.WriteAllLines(jsonPath, new[] { inputGraph }); 4517File.WriteAllLines(dataFile, new[] { 6587using (var stream = File.OpenRead(modelPath)) 6663using (var f = File.Open(outputPath, FileMode.Create, FileAccess.Write, FileShare.None))
UnitTests\TestModelLoad.cs (2)
27using (var modelStream = File.OpenRead(Path.Combine("TestModels", "BinaryLoader-v3.11.0.0.zip"))) 45using (var modelStream = File.OpenRead(Path.Combine("TestModels", "ConcatTransform.zip")))
UnitTests\TestResourceDownload.cs (5)
67if (File.Exists(Path.Combine(saveToDir, fileName))) 96if (File.Exists(Path.Combine(saveToDir, fileName))) 124if (!File.Exists(GetOutputPath("copyto", "sentiment.emd"))) 140if (File.Exists(GetOutputPath("copyto", "sentiment.emd"))) 141File.Delete(GetOutputPath("copyto", "sentiment.emd"));
Microsoft.ML.Data (8)
DataLoadSave\Binary\BinaryLoaderSaverCatalog.cs (1)
50if (!File.Exists(path))
DataLoadSave\Text\TextLoaderSaverCatalog.cs (1)
313if (!File.Exists(path) && StreamUtils.ExpandWildCards(path).Length < 1)
Model\ModelOperationsCatalog.cs (4)
71using (var stream = File.Create(filePath)) 118using (var stream = File.Create(filePath)) 215using (var stream = File.OpenRead(filePath)) 290using (var stream = File.OpenRead(filePath))
Utilities\StreamUtils.cs (2)
65if (File.Exists(pattern)) 158if (!File.Exists(currentPattern))
Microsoft.ML.EntryPoints (4)
JsonUtils\ExecuteGraphCommand.cs (4)
45_host.CheckUserArg(args.GraphPath != null && File.Exists(args.GraphPath), nameof(args.GraphPath), "Graph path does not exist"); 54graph = JObject.Parse(File.ReadAllText(_path)); 118using (var fs = File.OpenRead(path)) 124using (var fs = File.OpenRead(path))
Microsoft.ML.GenAI.Core.Tests (1)
CausalLMDatasetTest.cs (1)
25using Stream remoteStream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model"));
Microsoft.ML.GenAI.LLaMA (3)
LlamaForCausalLM.cs (2)
103var modelConfig = JsonSerializer.Deserialize<LlamaConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 136var modelConfig = JsonSerializer.Deserialize<LlamaConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
LlamaTokenizerHelper.cs (1)
53return TiktokenTokenizer.Create(File.OpenRead(modelFilePath), preTokenizer, normalizer: null, specialTokens: _specialTokens);
Microsoft.ML.GenAI.Mistral (3)
MistralForCausalLM.cs (2)
58var modelConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 86var modelConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
MistralTokenizerHelper.cs (1)
98var modelStream = File.OpenRead(modelPath);
Microsoft.ML.GenAI.Phi (6)
Phi2\Phi2ForCausalLM.cs (1)
59var modelConfig = JsonSerializer.Deserialize<Phi2Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
Phi2\Phi2TokenizerHelper.cs (2)
25using var vocabStream = File.OpenRead(vocabPath); 26using var mergesStream = File.OpenRead(mergesPath);
Phi3\Phi3ForCausalLM.cs (2)
60var modelConfig = JsonSerializer.Deserialize<Phi3Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 88var modelConfig = JsonSerializer.Deserialize<Phi3Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
Phi3\Phi3TokenizerHelper.cs (1)
35var modelStream = File.OpenRead(modelPath);
Microsoft.ML.GenAI.Samples (1)
Mistral\Mistral_7B_Instruct.cs (1)
76var mistralConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(Path.Combine(weightFolder, configName))) ?? throw new ArgumentNullException(nameof(configName));
Microsoft.ML.ImageAnalytics (2)
ImageLoader.cs (2)
251var bytes = File.ReadAllBytes(path); 312imageBuffer = File.ReadAllBytes(path);
Microsoft.ML.IntegrationTests (12)
DataIO.cs (2)
122using (var file = File.Create(filePath)) 131using (var file = File.Create(filePath))
ModelFiles.cs (7)
108using (var file = File.OpenRead(modelPath)) 165using (var fs = File.OpenRead(modelAndSchemaPath)) 167using (var fs = File.OpenRead(compositeLoaderModelPath)) 183using (var fs = File.OpenRead(loaderAndTransformerModelPath)) 285using (var fs = File.OpenRead(modelPath)) 340using (var fs = File.OpenRead(modelPath)) 479using (var fs = File.OpenRead(filename))
ONNX.cs (3)
52using (var file = File.Create(modelPath)) 102using (var file = File.Create(modelPath)) 154using (var file = File.Create(modelPath))
Microsoft.ML.Maml (1)
HelpCommand.cs (1)
490File.WriteAllText(_xmlFilename, content.ToString());
Microsoft.ML.OnnxTransformer (4)
OnnxTransform.cs (2)
263Host.CheckIO(File.Exists(options.ModelFile), "Model file {0} does not exists.", options.ModelFile); 424ctx.SaveBinaryStream("OnnxModel", w => { w.WriteByteArray(File.ReadAllBytes(Model.ModelStream.Name)); });
OnnxUtils.cs (2)
409File.WriteAllBytes(tempModelFile, modelBytes); 434using (var fileStream = File.Create(tempModelFile))
Microsoft.ML.OnnxTransformerTest (8)
OnnxTransformTests.cs (8)
241using FileStream fileStream = File.OpenRead(modelFile); 286File.Delete(tempPath); 337File.Delete(tempPath); 791var modelInBytes = File.ReadAllBytes(modelFile); 797Assert.True(File.Exists(onnxModel.ModelStream.Name)); 802Assert.False(File.Exists(onnxModel.ModelStream.Name)); 815Assert.True(File.Exists(onnxModel.ModelStream.Name)); 821Assert.True(File.Exists(onnxModel.ModelStream.Name));
Microsoft.ML.PerformanceTests (16)
BenchmarkBase.cs (1)
41if (File.Exists(filePath))
Harness\ProjectGenerator.cs (2)
38=> File.WriteAllText(artifactsPaths.ProjectFilePath, $@" 70return string.Join(Environment.NewLine, File.ReadAllLines(csproj.FullName).Where(line => line.Contains("<NativeAssemblyReference")));
ImageClassificationBench.cs (5)
161if (File.Exists(relativeFilePath)) 170File.Delete(relativeFilePath); 197if (File.Exists(Path.Combine(destFolder, flag))) return; 201File.Create(Path.Combine(destFolder, flag)); 233if (!overwrite && File.Exists(filename))
Numeric\Ranking.cs (5)
28if (!File.Exists(_mslrWeb10kValidate)) 31if (!File.Exists(_mslrWeb10kTrain)) 79if (!File.Exists(_mslrWeb10kTest)) 82if (!File.Exists(_mslrWeb10kValidate)) 85if (!File.Exists(_mslrWeb10kTrain))
RffTransform.cs (1)
24if (!File.Exists(_dataPathDigits))
Text\MultiClassClassification.cs (2)
25if (!File.Exists(_dataPathWiki)) 102if (!File.Exists(_dataPathWiki))
Microsoft.ML.Predictor.Tests (8)
CmdLine\CmdIndenterTest.cs (1)
48using (var writer = File.CreateText(outPath))
CmdLine\CmdLine.cs (1)
348using (var writer = File.CreateText(outPath))
ResultProcessor\TestResultProcessor.cs (1)
47File.WriteAllText(filePath, reader.ReadToEnd());
TestIniModels.cs (2)
540using (Stream iniStream = File.Create(modelIniPath)) 582using (Stream iniStream = File.Create(modelIniPath))
TestPredictors.cs (3)
1751File.WriteAllText(path, 1761File.WriteAllText(path, 1772File.WriteAllText(path,
Microsoft.ML.ResultProcessor (4)
ResultProcessor.cs (4)
717if (!File.Exists(filename)) 720rawLines = File.ReadAllLines(filename); 836var lines = File.ReadAllLines(filename); 1082? File.CreateText(cmd.OutputFile) : Console.Out);
Microsoft.ML.Samples (34)
Dynamic\DataOperations\LoadingSvmLight.cs (1)
19using (var fs = File.CreateText(fileName))
Dynamic\DataOperations\LoadingText.cs (1)
24using (var fs = File.CreateText(fileName))
Dynamic\ModelOperations\OnnxConversion.cs (2)
71using (var stream = File.Create("sample_onnx_conversion_1.onnx")) 79using (var stream = File.Create("sample_onnx_conversion_2.onnx"))
Dynamic\ModelOperations\SaveLoadModel.cs (1)
35using (var file = File.OpenRead("model.zip"))
Dynamic\TensorFlow\ImageClassification.cs (3)
26if (!File.Exists(modelLocation)) 120if (File.Exists(dataFile)) 141Stream inStream = File.OpenRead(path);
Dynamic\Trainers\MulticlassClassification\ImageClassification\ImageClassificationDefault.cs (5)
97using (var file = File.OpenRead("model.zip")) 232Image = File.ReadAllBytes(file), 264if (File.Exists(relativeFilePath)) 296if (File.Exists(Path.Combine(destFolder, flag))) return; 301File.Create(Path.Combine(destFolder, flag));
Dynamic\Trainers\MulticlassClassification\ImageClassification\LearningRateSchedulingCifarResnetTransferLearning.cs (5)
132using (var file = File.OpenRead("model.zip")) 262Image = File.ReadAllBytes(file), 296if (File.Exists(relativeFilePath)) 328if (File.Exists(Path.Combine(destFolder, flag))) return; 342File.Create(Path.Combine(destFolder, flag));
Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningEarlyStopping.cs (4)
122using (var file = File.OpenRead("model.zip")) 252if (File.Exists(relativeFilePath)) 284if (File.Exists(Path.Combine(destFolder, flag))) return; 298File.Create(Path.Combine(destFolder, flag));
Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningTrainTestSplit.cs (5)
114using (var file = File.OpenRead("model.zip")) 241Image = File.ReadAllBytes(file), 273if (File.Exists(relativeFilePath)) 305if (File.Exists(Path.Combine(destFolder, flag))) return; 319File.Create(Path.Combine(destFolder, flag));
Dynamic\Transforms\TimeSeries\DetectAnomalyBySrCnn.cs (1)
95using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\DetectChangePointBySsa.cs (1)
104using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\DetectIidChangePoint.cs (1)
102using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\DetectIidSpike.cs (1)
87using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\DetectSpikeBySsa.cs (1)
98using (var file = File.OpenRead(modelPath))
Dynamic\Transforms\TimeSeries\Forecasting.cs (1)
78using (var file = File.OpenRead("model.zip"))
Dynamic\Transforms\TimeSeries\ForecastingWithConfidenceInterval.cs (1)
83using (var file = File.OpenRead("model.zip"))
Microsoft.ML.Samples.GPU (22)
docs\samples\Microsoft.ML.Samples\Dynamic\TensorFlow\ImageClassification.cs (3)
26if (!File.Exists(modelLocation)) 120if (File.Exists(dataFile)) 141Stream inStream = File.OpenRead(path);
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ImageClassificationDefault.cs (5)
97using (var file = File.OpenRead("model.zip")) 232Image = File.ReadAllBytes(file), 264if (File.Exists(relativeFilePath)) 296if (File.Exists(Path.Combine(destFolder, flag))) return; 301File.Create(Path.Combine(destFolder, flag));
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\LearningRateSchedulingCifarResnetTransferLearning.cs (5)
132using (var file = File.OpenRead("model.zip")) 262Image = File.ReadAllBytes(file), 296if (File.Exists(relativeFilePath)) 328if (File.Exists(Path.Combine(destFolder, flag))) return; 342File.Create(Path.Combine(destFolder, flag));
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningEarlyStopping.cs (4)
122using (var file = File.OpenRead("model.zip")) 252if (File.Exists(relativeFilePath)) 284if (File.Exists(Path.Combine(destFolder, flag))) return; 298File.Create(Path.Combine(destFolder, flag));
docs\samples\Microsoft.ML.Samples\Dynamic\Trainers\MulticlassClassification\ImageClassification\ResnetV2101TransferLearningTrainTestSplit.cs (5)
114using (var file = File.OpenRead("model.zip")) 241Image = File.ReadAllBytes(file), 273if (File.Exists(relativeFilePath)) 305if (File.Exists(Path.Combine(destFolder, flag))) return; 319File.Create(Path.Combine(destFolder, flag));
Microsoft.ML.SamplesUtils (1)
SamplesDatasetUtils.cs (1)
193if (File.Exists(dataFile))
Microsoft.ML.Sweeper (4)
ConfigRunner.cs (4)
84if (!File.Exists(Exe) && !File.Exists(Exe + ".exe")) 211if (File.Exists(errorFile) && new FileInfo(errorFile).Length == 0) 213File.Delete(errorFile);
Microsoft.ML.TensorFlow (2)
TensorflowUtils.cs (2)
275FileAttributes attr = File.GetAttributes(modelPath); 408env.CheckUserArg(File.Exists(modelPath), nameof(modelPath));
Microsoft.ML.TensorFlow.Tests (13)
TensorflowTests.cs (13)
1432using (var file = File.OpenRead("model.zip")) 1449if (Directory.Exists(workspacePath) && File.Exists(Path.Combine(workspacePath, trainSetBottleneckCachedValuesFileName)) 1450&& File.Exists(Path.Combine(workspacePath, validationSetBottleneckCachedValuesFileName))) 1535using (var file = File.OpenRead("model.zip")) 1694using (var file = File.OpenRead("model.zip")) 1750Assert.True(File.Exists(Path.Combine(options.WorkspacePath, options.TrainSetBottleneckCachedValuesFileName))); 1751Assert.True(File.Exists(Path.Combine(options.WorkspacePath, options.ValidationSetBottleneckCachedValuesFileName))); 1752Assert.True(File.Exists(Path.Combine(Path.GetTempPath(), "MLNET", ImageClassificationTrainer.ModelFileName[options.Arch]))); 1825using (var file = File.OpenRead("model.zip")) 1896using (var file = File.OpenRead("model.zip")) 1985if (File.Exists(relativeFilePath)) 2012if (File.Exists(Path.Combine(destFolder, flag))) 2016File.Create(Path.Combine(destFolder, flag));
Microsoft.ML.TestFramework (43)
BaseTestBaseline.cs (10)
289if (File.Exists(baselinePath)) 336File.Delete(rawPath); 337File.Move(path, rawPath); 340using (TextWriter dst = File.CreateText(path)) 433File.Delete(outPath + RawSuffix); 940if (!File.Exists(outPath)) 954if (!File.Exists(basePath)) 1002return Utils.OpenWriter(File.Open(path, append ? FileMode.Append : FileMode.OpenOrCreate), encoding, bufferSize, false); 1014return new StreamReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)); 1045File.WriteAllText(path,
BaseTestPredictorsMaml.cs (2)
264File.Delete(consOutPath2.Path); 288File.Delete(outPath);
DataPipe\TestDataPipe.cs (19)
53File.WriteAllLines(mappingPathData, 73File.WriteAllLines(mappingPathData, 93File.WriteAllLines(mappingPathData, 113File.WriteAllLines(mappingPathData, 143File.WriteAllLines(mappingPathData, 169File.WriteAllLines(pathTerms, new string[] { 192File.WriteAllLines(pathTerms, new string[] { 250File.WriteAllLines(pathData, new string[] { 296File.WriteAllLines(pathData, 344File.WriteAllLines(dataFile, _small20NewsGroupSample); 347File.WriteAllLines(dictFile, _small20NewsGroupDict); 429File.WriteAllLines(pathData, 654File.WriteAllLines(pathData, 736File.WriteAllLines(pathData, 889File.WriteAllLines(dataFile, new[] { 908File.WriteAllLines(stopwordsFile, stopwordsList); 960File.WriteAllLines(dataFile, new[] { 984File.WriteAllLines(pathData, 1042File.WriteAllLines(pathData, new string[] {
DataPipe\TestDataPipeBase.cs (4)
87using (var fs = File.OpenRead(modelPath)) 395using (var stream = File.Create(pathData)) 541using (var stream = File.Create(pathData)) 592using (var stream = File.Create(pathData))
TestCommandBase.cs (8)
353File.Delete(testOutPath + RawSuffix); 756File.WriteAllLines(path.Path, new string[] { 772File.WriteAllLines(path2.Path, new string[] { 1305File.WriteAllLines(dataPath.Path, new string[] { 2238File.WriteAllLines(path.Path, new string[] { 2260File.WriteAllLines(path.Path, new string[] { 2270File.WriteAllLines(path.Path, new string[] { 2278File.WriteAllLines(path.Path, new string[] { "1 aurora:2 :3" });
Microsoft.ML.TestFrameworkCommon (3)
TestCommon.cs (2)
47File.Delete(path); 54File.Delete(path);
Utility\LibraryLoader.cs (1)
99if (!Path.IsPathRooted(loadTarget) || File.Exists(loadTarget))
Microsoft.ML.Tests (77)
BinaryLoaderSaverTests.cs (1)
29using (var fs = File.Create(outputPath))
FeatureContributionTests.cs (1)
244using (var fs = File.Create(outputPath))
OnnxConversionTest.cs (13)
450var fileText = File.ReadAllText(onnxTextPath); 452File.WriteAllText(onnxTextPath, fileText); 703File.WriteAllLines(jsonPath, new[] { inputGraph }); 735File.WriteAllLines(jsonPath, new[] { inputGraph }); 747using (var modelStream = File.OpenRead(onnxPath)) 756File.Delete(modelPath); 757File.Delete(onnxPath); 758File.Delete(onnxJsonPath); 1026File.WriteAllLines(dataFile, 1729using (var stream = File.Create(onnxModelPath)) 1735using (var modelStream = File.OpenRead(onnxModelPath)) 2288var fileText = File.ReadAllText(textFormatPath); 2291File.WriteAllText(textFormatPath, fileText);
Scenarios\Api\TestApi.cs (2)
166using (var fs = File.Create(GetOutputPath(OutputRelativePath, "lambda-output.tsv"))) 271var data = File.ReadAllLines(dataFile)
SvmLightTests.cs (5)
37File.WriteAllLines(path, data); 49using (var stream = File.Create(savingPath)) 174using (var stream = File.Create(outputPath)) 197using (var stream = File.Create(outputPath)) 220using (var stream = File.Create(outputPath))
TermEstimatorTests.cs (1)
86using (var fs = File.Create(outputPath))
TextLoaderTests.cs (7)
34File.WriteAllLines(pathData, new string[] { 94File.WriteAllLines(pathData, new string[] { 119File.WriteAllLines(pathData, new string[] { 817using (FileStream modelfs = File.OpenRead(textLoaderModelPath)) 837using (FileStream modelfs = File.OpenRead(textLoaderModelPath)) 1306using (var fs = File.Create(savedPath)) 1384File.WriteAllText(filePath, badInputCsv);
TrainerEstimators\CalibratorEstimators.cs (1)
258using (var fs = File.OpenRead(modelPath))
TrainerEstimators\LbfgsTests.cs (4)
125using (var fs = File.OpenRead(modelAndSchemaPath)) 146using (FileStream fs = File.OpenRead(dropModelPath)) 220using (var fs = File.OpenRead(modelAndSchemaPath)) 237using (FileStream fs = File.OpenRead(dropModelPath))
TrainerEstimators\MatrixFactorizationTests.cs (1)
541using (var fs = File.OpenRead(modelPath))
Transformers\CategoricalHashTests.cs (2)
71using (var fs = File.Create(outputPath)) 104using (var fs = File.Create(outputPath))
Transformers\CategoricalTests.cs (2)
90using (var fs = File.Create(outputPath)) 176using (var fs = File.Create(outputPath))
Transformers\ConcatTests.cs (2)
90using (var fs = File.Create(outputPath)) 154using (var fs = File.Create(outputPath))
Transformers\ConvertTests.cs (1)
395using (var fs = File.OpenRead(modelPath))
Transformers\FeatureSelectionTests.cs (4)
53using (var fs = File.Create(outputPath)) 88using (var fs = File.Create(outputPath)) 130using (var fs = File.Create(outputPath)) 190using (var fs = File.Create(outputPath))
Transformers\HashTests.cs (1)
344using (var fs = File.Create(outputPath))
Transformers\KeyToValueTests.cs (1)
56using (var fs = File.Create(outputPath))
Transformers\NAIndicatorTests.cs (1)
118using (var fs = File.Create(outputPath))
Transformers\NAReplaceTests.cs (1)
145using (var fs = File.Create(outputPath))
Transformers\NormalizerTests.cs (7)
88using (var fs = File.Create(outputPath)) 678using (var fs = File.Create(outputPath)) 712using (var fs = File.Create(outputPath)) 775using (var fs = File.Create(outputPath)) 835using (var fs = File.Create(outputPath)) 876using (FileStream fs = File.OpenRead(chooseModelPath)) 1012using (var fs = File.Create(outputPath))
Transformers\PcaTests.cs (1)
63using (var fs = File.Create(outputPath))
Transformers\RffTests.cs (1)
78using (var fs = File.Create(outputPath))
Transformers\SelectColumnsTests.cs (4)
221using (FileStream fs = File.OpenRead(dropModelPath)) 249using (FileStream fs = File.OpenRead(dropModelPath)) 277using (FileStream fs = File.OpenRead(dropModelPath)) 305using (FileStream fs = File.OpenRead(chooseModelPath))
Transformers\TextFeaturizerTests.cs (8)
447using (var fs = File.Create(outputPath)) 478using (var fs = File.Create(outputPath)) 502using (var fs = File.Create(outputPath)) 546using (var fs = File.Create(outputPath)) 608using (var fs = File.Create(outputPath)) 643using (var fs = File.Create(outputPath)) 660using (FileStream fs = File.OpenRead(dropModelPath)) 702using (var fs = File.Create(outputPath))
Transformers\TextNormalizer.cs (1)
64using (var fs = File.Create(outputPath))
Transformers\ValueMappingTests.cs (2)
717using (FileStream fs = File.OpenRead(termLookupModelPath)) 734using (FileStream fs = File.OpenRead(termLookupModelPath))
Transformers\WordEmbeddingsTests.cs (2)
54using (var fs = File.Create(outputPath)) 97using (var fs = File.Create(outputPath))
Microsoft.ML.TimeSeries (1)
PredictionEngine.cs (1)
90using (var file = File.Create(modelPath))
Microsoft.ML.TimeSeries.Tests (5)
TimeSeries.cs (1)
81File.WriteAllLines(pathData, Enumerable.Repeat("0", 50));
TimeSeriesDirectApi.cs (4)
251using (var file = File.OpenRead(modelPath)) 271using (var file = File.OpenRead(modelPath + 1)) 339using (var file = File.OpenRead(modelPath)) 494using (var file = File.OpenRead("model.zip"))
Microsoft.ML.Tokenizers (17)
Model\BertTokenizer.cs (2)
665string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath), 722Stream stream = string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath);
Model\BpeOptions.cs (4)
44if (!File.Exists(vocabFile)) 49using Stream vocabStream = File.OpenRead(vocabFile); 61if (!File.Exists(mergesFile)) 66using Stream mergesStream = File.OpenRead(mergesFile);
Model\BPETokenizer.cs (2)
127using Stream vocabStream = File.OpenRead(vocabFile); 128using Stream? mergesStream = mergesFile is null ? null : File.OpenRead(mergesFile);
Model\CodeGenTokenizer.cs (2)
67this(vocabularyPath is null ? throw new ArgumentNullException(nameof(vocabularyPath)) : File.OpenRead(vocabularyPath), 68mergePath is null ? throw new ArgumentNullException(nameof(mergePath)) : File.OpenRead(mergePath),
Model\EnglishRobertaTokenizer.cs (3)
119this(vocabularyPath is null ? throw new ArgumentNullException(nameof(vocabularyPath)) : File.OpenRead(vocabularyPath), 120mergePath is null ? throw new ArgumentNullException(nameof(mergePath)) : File.OpenRead(mergePath), 121highestOccurrenceMappingPath is null ? throw new ArgumentNullException(nameof(highestOccurrenceMappingPath)) : File.OpenRead(highestOccurrenceMappingPath),
Model\TiktokenTokenizer.cs (2)
47this(string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath), preTokenizer, specialTokens, normalizer, cacheSize, disposeStream: true) 1428using Stream vocabStream = File.OpenRead(vocabFilePath);
Model\WordPieceTokenizer.cs (2)
134Create(string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath), options, disposeStream: true); 192string.IsNullOrEmpty(vocabFilePath) ? throw new ArgumentNullException(nameof(vocabFilePath)) : File.OpenRead(vocabFilePath),
Microsoft.ML.Tokenizers.Data.Tests (3)
test\Microsoft.ML.Tokenizers.Tests\Utils.cs (3)
41if (File.Exists(file)) 45File.Delete(file); 58using Stream fileStream = File.Create(fileName);
Microsoft.ML.Tokenizers.Tests (59)
BertTokenizerTests.cs (16)
41using Stream vocabStream = File.OpenRead(vocabFile); 98File.Delete(vocabFile); 112using Stream vocabStream = File.OpenRead(vocabFile); 169File.Delete(vocabFile); 183using Stream vocabStream = File.OpenRead(vocabFile); 219File.Delete(vocabFile); 234using Stream vocabStream = File.OpenRead(vocabFile); 296File.Delete(vocabFile); 309using Stream vocabStream = File.OpenRead(vocabFile); 348File.Delete(vocabFile); 362using Stream vocabStream = File.OpenRead(vocabFile); 448File.Delete(vocabFile); 462using Stream vocabStream = File.OpenRead(vocabFile); 541File.Delete(vocabFile); 555using Stream vocabStream = File.OpenRead(vocabFile); 599File.Delete(vocabFile);
BpeTests.cs (10)
366using Stream vocabStream = File.OpenRead(Path.Combine(@"Gpt-2", "vocab.json")); 367using Stream mergesStream = File.OpenRead(Path.Combine(@"Gpt-2", "merges.txt")); 386using Stream vocabStream = File.OpenRead(vocabFile); 387using Stream mergesStream = File.OpenRead(mergesFile); 399string jsonString = File.ReadAllText(vocabFile); 405Merges = File.ReadAllLines(mergesFile).Skip(1).ToArray() // Skip the first line which is the header "#version". 546using Stream vocabStream = File.OpenRead(Path.Combine(@"Gpt-2", "vocab.json")); 547using Stream mergesStream = File.OpenRead(Path.Combine(@"Gpt-2", "merges.txt")); 592File.WriteAllText(fileName, JsonSerializer.Serialize<Dictionary<string, int>>(dic), Encoding.UTF8); 951using Stream jsonModelStream = File.OpenRead(Path.Combine(@"DeepSeek", "tokenizer-DeepSeek-R1.json"));
CodeGenTests.cs (4)
28using Stream vocabStream = File.OpenRead(Path.Combine(@"Codegen-350M-mono", "vocab.json")); 29using Stream mergesStream = File.OpenRead(Path.Combine(@"Codegen-350M-mono", "merges.txt")); 39using Stream vocabStream = File.OpenRead(Path.Combine(@"Phi-2", "vocab.json")); 40using Stream mergesStream = File.OpenRead(Path.Combine(@"Phi-2", "merges.txt"));
EnglishRobertaTests.cs (3)
122using Stream vocabStream = File.OpenRead(vocabFile); 123using Stream mergeStream = File.OpenRead(mergeFile); 124using Stream translationStream = File.OpenRead(translationFile);
LlamaTests.cs (3)
32using Stream remoteStream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model")); 39using Stream remoteStream = File.OpenRead(Path.Combine(@"Mistral", "tokenizer.model")); 46using Stream remoteStream = File.OpenRead(Path.Combine(@"Llama", "tokenizer.model"));
TiktokenTests.cs (12)
58using (Stream fileStream = File.OpenWrite(tokenizerDataFileName)) 68using (Stream stream = File.OpenRead(tokenizerDataFileName)) 77using (Stream stream = File.OpenRead(tokenizerDataFileName)) 83using (Stream stream = File.OpenRead(tokenizerDataFileName)) 89using (Stream stream = File.OpenRead(tokenizerDataFileName)) 224using (Stream stream = File.OpenRead("./Data/tokens.json")) 299using (Stream stream = File.OpenRead("./Data/tokens_gpt4o.json")) 336using (Stream stream = File.OpenRead("./Data/tokens_gpt2.json")) 355using (Stream stream = File.OpenRead("./Data/tokens_p50k_base.json")) 374using (Stream stream = File.OpenRead("./Data/tokens_p50k_edit.json")) 393using (Stream stream = File.OpenRead("./Data/tokens_r50k_base.json")) 669string text = File.ReadAllText(path);
UnigramTests.cs (2)
26using Stream remoteStream = File.OpenRead(Path.Combine(@"Paraphrase-multilingual-MiniLM-L12-v2", "sentencepiece.bpe.model")); 58using Stream remoteStream = File.OpenRead(Path.Combine(@"Paraphrase-multilingual-MiniLM-L12-v2", "sentencepiece.bpe.model"));
Utils.cs (3)
41if (File.Exists(file)) 45File.Delete(file); 58using Stream fileStream = File.Create(fileName);
WordPieceTests.cs (6)
21File.WriteAllLines(vocabFile, vocabTokens); 32using Stream vocabStream = File.OpenRead(vocabFile); 47File.Delete(vocabFile); 141File.Delete(vocabFile); 173File.Delete(vocabFile); 217File.Delete(vocabFile);
Microsoft.ML.Transforms (6)
LoadTransform.cs (1)
71h.CheckUserArg(File.Exists(args.ModelFile), nameof(args.ModelFile), "File does not exist");
SvmLight\SvmLightLoaderSaverCatalog.cs (2)
72if (!File.Exists(path)) 94if (!File.Exists(path))
Text\WordEmbeddingsExtractor.cs (3)
653if (!File.Exists(_modelFileNameWithPath)) 682Parallel.ForEach(File.ReadLines(_modelFileNameWithPath).Skip(skippedLinesCount), GetParallelOptions(hostEnvironment), 706var firstLine = File.ReadLines(_modelFileNameWithPath).First();
Microsoft.ML.Vision (21)
DnnRetrainTransform.cs (5)
420File.Copy(f, Path.Combine(archivePath, Path.GetFileName(f))); 440if (File.Exists(destination)) 441File.Delete(destination); 447if (File.Exists(destination)) 448File.Delete(destination);
ImageClassificationTrainer.cs (16)
676File.Exists(validationSetBottleneckCachedValuesFilePath + "_features.bin") && 677File.Exists(validationSetBottleneckCachedValuesFilePath + "_labels.bin"); 693!(File.Exists(trainSetBottleneckCachedValuesFilePath + "_features.bin") && 694File.Exists(trainSetBottleneckCachedValuesFilePath + "_labels.bin"))) 871using Stream featuresWriter = File.Open(cacheFilePath + "_features.bin", FileMode.Create); 872using Stream labelWriter = File.Open(cacheFilePath + "_labels.bin", FileMode.Create); 873using TextWriter writer = File.CreateText(cacheFilePath); 902(File.Exists(validationSetBottleneckFilePath + "_labels.bin") && 903File.Exists(validationSetBottleneckFilePath + "_features.bin"))); 906File.Exists(trainBottleneckFilePath + "_labels.bin") && 907File.Exists(trainBottleneckFilePath + "_features.bin")); 913using (Stream trainSetLabelReader = File.Open(trainBottleneckFilePath + "_labels.bin", FileMode.Open)) 914using (Stream trainSetFeatureReader = File.Open(trainBottleneckFilePath + "_features.bin", FileMode.Open)) 917File.Open(validationSetBottleneckFilePath + "_labels.bin", FileMode.Open) : null; 920File.Open(validationSetBottleneckFilePath + "_features.bin", FileMode.Open) : null; 1196File.WriteAllBytes(_checkpointPath + ".pb", outputGraphDef.ToByteArray());
Microsoft.NETCore.Platforms (2)
UpdateRuntimeIdentifierGraph.cs (2)
28using (StreamReader streamReader = File.OpenText(InputFile!)) 47using StreamWriter streamWriter = File.CreateText(OutputFile!);
Microsoft.VisualBasic.Core (27)
Microsoft\VisualBasic\CompilerServices\VB6File.vb (1)
404If File.Exists(m_sFullPath) Then
Microsoft\VisualBasic\CompilerServices\VB6OutputFile.vb (1)
42If File.Exists(m_sFullPath) Then
Microsoft\VisualBasic\CompilerServices\VB6RandomFile.vb (1)
62If File.Exists(m_sFullPath) Then
Microsoft\VisualBasic\FileIO\FileSystem.vb (18)
97Return IO.File.Exists(file) 347Return IO.File.ReadAllBytes(file) 357Return IO.File.ReadAllText(file) 368Return IO.File.ReadAllText(file, encoding) 478If IO.File.Exists(directory) Then 710If Not IO.File.Exists(file) Then 728IO.File.Move(file, FullNewPath) 795If append AndAlso IO.File.Exists(file) Then 920If IO.File.Exists(TargetDirectoryFullPath) Then 1110If Not IO.File.Exists(sourceFileFullPath) Then 1136IO.File.Copy(sourceFileFullPath, destinationFileFullPath, overwrite) 1159IO.File.Delete(destinationFileFullPath) 1161IO.File.Move(sourceFileFullPath, destinationFileFullPath) 1164IO.File.Move(sourceFileFullPath, destinationFileFullPath) 1230If Not IO.File.Exists(fileFullPath) Then 1240IO.File.Delete(fileFullPath) 1249If IO.File.Exists(Path) Then 1496If IO.File.Exists(FullPath) Then
Microsoft\VisualBasic\FileIO\TextFieldParser.vb (1)
600If Not File.Exists(fullPath) Then
Microsoft\VisualBasic\FileSystem.vb (5)
284File.Copy(Source, Destination, True) 287File.SetAttributes(Destination, FileAttributes.Archive) 307If File.Exists(PathName) Then 318If File.Exists(PathName) Then 415IO.File.Delete(FileName)
Microsoft.VisualBasic.Forms.Tests (22)
System\Windows\Forms\FileLogTraceListenerTests.vb (8)
154If File.Exists(fullLogFileName) Then 155File.Delete(fullLogFileName) 220If File.Exists(fullLogFileName) Then 221File.Delete(fullLogFileName) 241If File.Exists(fullLogFileName) Then 242File.Delete(fullLogFileName) 262If File.Exists(fullLogFileName) Then 263File.Delete(fullLogFileName)
System\Windows\Forms\FileSystemProxyTests.vb (10)
102File.Exists(sourceFileName).Should.BeTrue() 118File.Exists(sourceFileName).Should.BeTrue() 133File.Exists(sourceFileName).Should.BeTrue() 139File.Exists(sourceFileName).Should.BeFalse() 152File.Exists(sourceFileName).Should.BeTrue() 159File.Exists(sourceFileName).Should.BeFalse() 239File.Exists(sourceFileName).Should.BeFalse() 240File.Exists(file2).Should.BeTrue() 259File.Exists(sourceFileName).Should.BeFalse() 260File.Exists(destinationFileName).Should.BeTrue()
System\Windows\Forms\VbFileCleanupTestBaseTests.vb (1)
51File.Exists(testFile1).Should.BeFalse()
System\Windows\TestUtilities\VbFileCleanupTestBase.vb (3)
52Using destinationStream As FileStream = File.Create(filenameWithPath) 72Using stream As FileStream = File.Create(path) 75File.Delete(path)
Microsoft.VisualBasic.Tests (24)
Microsoft\VisualBasic\MyServices\FileSystemProxyTests.cs (24)
19string actualData = File.ReadAllText(FileNameWithPath); 25File.WriteAllText(FileName, TestData); 212Assert.True(File.Exists(testFileSource)); 225Assert.True(File.Exists(testFileSource)); 228Assert.True(File.Exists(testFileSource)); 236Assert.True(File.Exists(testFileSource)); 238Assert.False(File.Exists(testFileSource)); 257File.Delete(testFileSource); 437Assert.True(File.Exists(FileList[i])); 483Assert.True(File.Exists(TempFile)); 485File.Delete(TempFile); 580Assert.False(File.Exists(SourceFileNameWithPath)); 581Assert.True(File.Exists(DestinationFileNameWithPath)); 589Assert.True(File.Exists(SourceFileNameWithPath)); 598Assert.False(File.Exists(SourceFileNameWithPath)); 599Assert.True(File.Exists(DestinationFileNameWithPath)); 606Assert.True(File.Exists(SourceFileNameWithPath)); 615Assert.False(File.Exists(SourceFileNameWithPath)); 616Assert.True(File.Exists(DestinationFileNameWithPath)); 620Assert.True(File.Exists(SourceFileNameWithPath)); 621Assert.False(File.Exists(DestinationFileNameWithPath)); 674Assert.True(File.Exists(NewFileWithPath)); 675Assert.False(File.Exists(OrigFileWithPath)); 705Assert.False(File.Exists(TempFileNameWithPath), $"File {TempFileNameWithPath} should not exist!");
Microsoft.VisualStudio.LanguageServices (17)
CodeCleanup\AbstractCodeCleanUpFixer.cs (1)
105var attr = File.GetAttributes(path);
EditAndContinue\EditAndContinueFeedbackDiagnosticFileProvider.cs (3)
77if (File.Exists(_vsFeedbackSemaphoreFullPath)) 143if (_vsProcessStartTime > File.GetCreationTime(semaphoreFilePath)) 150var content = File.ReadAllText(semaphoreFilePath);
GenerateType\GenerateTypeDialogViewModel.cs (1)
360File.Exists(FullFilePath))
Implementation\AbstractEditorFactory.cs (1)
409using var stream = File.OpenRead(editorConfigFile);
ProjectSystem\Legacy\AbstractLegacyProject.cs (1)
77if (projectFilePath != null && !File.Exists(projectFilePath))
ProjectSystem\Legacy\AbstractLegacyProject_IVsHierarchyEvents.cs (1)
64if (filePath != null && File.Exists(filePath))
ProjectSystem\MiscellaneousFilesWorkspace.cs (1)
137let fullPath = FileUtilities.ResolveRelativePath(fileName, basePath: null, baseDirectory: null, searchPaths: searchPaths, fileExists: File.Exists)
ProjectSystem\VisualStudioWorkspaceImpl.cs (1)
890if (IOUtilities.PerformIO(() => File.Exists(documentInfo.FilePath)))
Telemetry\FileLogger.cs (2)
105if (!File.Exists(_logFilePath)) 110File.AppendAllText(_logFilePath, buffer.ToString());
UnusedReferences\ProjectAssets\ProjectAssetsFileReader.cs (2)
22var doesProjectAssetsFileExist = IOUtilities.PerformIO(() => File.Exists(projectAssetsFilePath)); 30using var fileStream = File.OpenRead(projectAssetsFilePath);
Watson\FaultReporter.cs (1)
330var lastWrite = File.GetLastWriteTimeUtc(path);
Workspace\SourceGeneratedFileManager.cs (2)
145if (!File.Exists(temporaryFilePath)) 146File.WriteAllText(temporaryFilePath, "");
Microsoft.VisualStudio.LanguageServices.CSharp (2)
SemanticSearch\SemanticSearchToolWindowImpl.cs (2)
476File.Delete(filePath); 480File.WriteAllText(filePath, newContent, Encoding.UTF8);
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
ProjectSystemShim\LegacyProject\AnalyzersTests.cs (1)
260File.WriteAllText(ruleSetFile.Path, ruleSetSource.Replace("Error", "Warning"));
Microsoft.VisualStudio.LanguageServices.Implementation (4)
CodeModel\RootCodeModel.cs (1)
75using (FileUtilities.CreateFileStreamChecked(File.Create, absoluteFilePath))
Options\GridOptionPreviewControl.xaml.cs (1)
121File.WriteAllText(filePath, editorconfig.ToString());
ProjectSystem\CPS\TempPECompiler.cs (1)
90using var file = FileUtilities.CreateFileStreamChecked(File.Create, outputFileName, nameof(outputFileName));
SolutionExplorer\AnalyzersCommandHandler.cs (1)
540File.Copy(pathToRuleSet, fullFilePath);
Microsoft.VisualStudio.LanguageServices.LiveShare (2)
Client\Projects\WorkspaceFileTextLoaderNoException.cs (1)
30if (!File.Exists(Path))
Client\RemoteLanguageServiceWorkspace.cs (1)
302text = SourceText.From(File.ReadAllText(document.FilePath));
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
319[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.File))]
Mvc.Api.Analyzers.Test (2)
Infrastructure\MvcTestSource.cs (2)
16if (!File.Exists(filePath)) 21var fileContent = File.ReadAllText(filePath);
netstandard (1)
netstandard.cs (1)
914[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.File))]
Pipelines.AppHost (1)
AppHost.cs (1)
312using var fileStream = File.OpenRead(filePath);
Pipelines.Library (3)
DistributedApplicationPipelineExtensions.cs (3)
152await using var zipStream = File.OpenRead(zipPath); 175if (File.Exists(zipPath)) 177File.Delete(zipPath);
PrepareTests (6)
MinimizeUtil.cs (6)
104if (isUnix && !OperatingSystem.IsWindows() && File.GetUnixFileMode(sourceFilePath).HasFlag(UnixFileMode.UserExecute)) 180File.WriteAllText(Path.Combine(destinationDirectory, group.Key, fileName), builder.ToString()); 193Contract.Assert(!File.Exists(file)); 194File.WriteAllText(file, "echo \"Nothing to rehydrate\""); 199File.WriteAllText(Path.Combine(destinationDirectory, rehydrateAllFilename), rehydrateAllBuilder.ToString()); 347using var stream = File.OpenRead(filePath);
PresentationBuildTasks (20)
Microsoft\Build\Tasks\Windows\GenerateTemporaryTargetAssembly.cs (4)
117using(FileStream fs = File.OpenRead(CurrentProject)) 195File.Delete(tempProj); 246using(FileStream fs = File.OpenRead(CurrentProject)) 310File.Delete(TemporaryTargetAssemblyProjectName);
Microsoft\Build\Tasks\Windows\ResourcesGenerator.cs (1)
293if (!File.Exists(TaskHelper.CreateFullFilePath(strFileName, SourceDir)))
Microsoft\Build\Tasks\Windows\UidManager.cs (6)
246using (Stream source = File.OpenRead(inputFile.ItemSpec)) 300using (Stream source = File.OpenRead(inputFile.ItemSpec)) 369File.Move(src, dest); 374if (File.Exists(fileName)) 376File.Delete(fileName); 479using (Stream xamlStream = File.OpenRead(fileName))
MS\Internal\Shared\SourceFileInfo.cs (1)
120_stream = File.OpenRead(_filePath);
MS\Internal\Tasks\CompilerState.cs (1)
163stream = File.OpenRead(_stateFilePath);
MS\Internal\Tasks\TaskFileService.cs (6)
151fileStream = File.OpenRead(srcFile); 199using (Stream fileStream = File.OpenRead(fileName)) 227lastChangeDT = File.GetLastWriteTime(srcFile); 252fileExists = File.Exists(fileName); 274File.Delete(fileName); 356File.Copy(buildFile, intelFile, /*overwrite*/ true);
src\Microsoft.DotNet.Wpf\src\PresentationFramework\System\Windows\Markup\XmlnsCache.cs (1)
110if (!String.IsNullOrEmpty(assemblyFullPath) && File.Exists(assemblyFullPath))
PresentationCore (4)
MS\Internal\AppModel\SiteOfOriginPart.cs (1)
170return File.OpenRead(_absoluteLocation.LocalPath);
MS\Internal\IO\Packaging\ByteRangeDownloader.cs (1)
60_tempFileStream = File.Open(tempFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
src\Microsoft.DotNet.Wpf\src\Shared\System\IO\FileHelper.cs (1)
154File.Delete(filePath);
System\Windows\Input\Cursor.cs (1)
256File.Delete(filePath);
PresentationCore.Tests (4)
System\Windows\Media\Imaging\BitmapImage.Tests.cs (4)
65File.WriteAllBytes(tempFile, "invalid image"u8.ToArray()); 80File.Delete(tempFile); 91File.WriteAllBytes(tempFile, s_png120DPI1x1); 115File.Delete(tempFile);
PresentationFramework (9)
Microsoft\Win32\FileDialog.cs (2)
459fileExists = File.Exists(tempPath); 600if (!GetOption(FOS.FILEMUSTEXIST) || File.Exists(newFilename))
Microsoft\Win32\SaveFileDialog.cs (1)
187bool fExist = File.Exists(fileName);
MS\Internal\AppModel\ContentFilePart.cs (1)
123return System.IO.File.Open(filename, FileMode.Open, FileAccess.Read, ResourceContainer.FileShare);
System\Windows\Controls\VirtualizingStackPanel.cs (1)
12578_writer = new BinaryWriter(File.Open(filename, FileMode.Create));
System\Windows\Documents\Speller.cs (1)
1581System.IO.File.Delete(tempLocationUri.LocalPath);
System\Windows\Documents\TextStore.cs (1)
5053_writer = new BinaryWriter(File.Open(filename, FileMode.Create));
System\Windows\Documents\WinRTSpellerInterop.cs (1)
428if (!File.Exists(lexiconFilePath))
System\Windows\Standard\Verify.cs (1)
265if (!File.Exists(filePath))
PresentationUI (23)
InstallationError.xaml.cs (1)
175if (File.Exists(LogFilePath) && ErrorFlag)
MS\Internal\Documents\Application\DocumentStream.cs (19)
118File.Copy(sourcePath, copiesPath, true); 123FileAttributes attrib = File.GetAttributes(copiesPath); 126File.SetAttributes(copiesPath, attrib ^ FileAttributes.ReadOnly); 264File.Copy(sourcePath, tempPath, true); 315if (File.Exists(path)) 317attributes = File.GetAttributes(path); 689File.Delete(path); 750File.SetAttributes( 854if (File.Exists(targetFile)) 865if( File.Exists( backupFile ) ) 868File.SetAttributes(backupFile, FileAttributes.Normal); 869File.Delete(backupFile); 874targetAttributes = File.GetAttributes(targetFile); 875File.Move(targetFile, backupFile); 889File.SetAttributes(backupFile, FileAttributes.Normal); 892File.Move(sourceFile, targetFile); 907File.Move(backupFile, targetFile); 914File.SetAttributes(targetFile, targetAttributes); 925File.Delete(backupFile);
MS\Internal\Documents\RightsManagementManager.cs (2)
862foundRMClient = File.Exists(msdrmdllPath); 1436template = File.ReadAllText(templateLocalPath, Encoding.Unicode);
TenFeetInstallationError.xaml.cs (1)
179if (File.Exists(LogFilePath) && ErrorFlag)
Replay (6)
src\Compilers\Shared\BuildServerConnection.cs (4)
439if (!File.Exists(processFilePath)) 529if (!File.Exists(serverInfo.processFilePath)) 821if (!File.Exists(FilePath)) 851File.Delete(FilePath);
src\Compilers\Shared\RuntimeHostInfo.cs (2)
43var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 91if (File.Exists(filePath))
Roslyn.Compilers.Extension (3)
CompilerPackage.cs (3)
122if (File.Exists(fileAndContents.Key) && File.ReadAllText(fileAndContents.Key) == fileAndContents.Value) 127File.WriteAllText(fileAndContents.Key, fileAndContents.Value);
Roslyn.Diagnostics.Analyzers (5)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
Roslyn.Test.Performance.Utilities (11)
Benchview.cs (2)
93System.Console.Write(System.IO.File.ReadAllText(submissionJson)); 109if (!File.Exists(source))
Logger.cs (1)
58File.AppendAllText(_file, _buffer.ToString());
RelativeDirectory.cs (2)
107if (File.Exists(zipPath)) 117File.Delete(path);
ScenarioGenerator.cs (3)
68if (File.Exists(_fullPath)) 71File.Delete(_fullPath); 75File.WriteAllLines(_fullPath, _buffer);
TraceManager.cs (1)
20if (File.Exists(cpcFullPath))
VsPerfTest.cs (2)
60var template = File.ReadAllText(taoTestFileTemplatePath); 68File.WriteAllText(Path.Combine(TempDirectory, _testTemplateName), finalTest);
Roslyn.VisualStudio.DiagnosticsWindow (1)
Panels\WorkspacePanel.xaml.cs (1)
94using var fileStream = File.OpenRead(document.FilePath);
RulesetToEditorconfigConverter (2)
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
RulesetToEditorconfigConverter.UnitTests (3)
RulesetToEditorconfigConverterTests.cs (3)
23File.WriteAllText(ruleset, rulesetText); 29File.WriteAllText(includedRuleset, includedRulesetText); 35var actualEditorConfigText = File.ReadAllText(editorconfigPath).Trim();
RunTests (25)
AssemblyScheduler.cs (3)
252if (!File.Exists(testListPath)) 257var deserialized = JsonSerializer.Deserialize<List<string>>(File.ReadAllText(testListPath)); 287using var stream = File.OpenRead(assemblyFilePath);
FileUtil.cs (2)
34if (File.Exists(filePath)) 36File.Delete(filePath);
HelixTestRunner.cs (9)
81File.WriteAllText(helixFilePath, helixProjectFileContent); 98File.Copy(helixFilePath, Path.Combine(logsDir, "helix.proj")); 214File.WriteAllText( 221File.CreateSymbolicLink( 226File.WriteAllText(Path.Combine(workItemPayloadDir, commandFileName), commandContent); 229File.WriteAllText(Path.Combine(workItemPayloadDir, postCommandFileName), postCommandContent); 391var globalJson = JsonConvert.DeserializeAnonymousType(File.ReadAllText(globalJsonFilePath), new { sdk = new { version = "" } }) 401if (File.Exists(globalJsonPath)) 491File.Copy(filePath, destinationPath);
Options.cs (2)
222if (dotnetFilePath is null || !File.Exists(dotnetFilePath)) 277while (dir != null && !File.Exists(Path.Combine(dir, programName)))
ProcessRunner.cs (1)
51if (File.Exists(file))
ProcessTestExecutor.cs (4)
117File.WriteAllText(rspFilePath, rspFileContents); 134File.Create(resultsFilePath).Close(); 163resultData = File.ReadAllText(resultsFilePath).Trim(); 173File.Delete(resultsFilePath);
Program.cs (3)
243if (File.Exists(dumpFilePath)) 320if (File.Exists(filePath)) 433File.Delete(dumpFile);
TestRunner.cs (1)
209File.WriteAllText(outputLogPath, testResult.StandardOutput ?? "");
Security.TransportSecurity.IntegrationTests (1)
Tcp\ClientCredentialTypeTests.OSX.cs (1)
133if (!File.Exists(ServiceUtilHelper.OSXCustomKeychainFilePath))
SemanticSearch.BuildTask (7)
GenerateFilteredReferenceAssembliesTask.cs (7)
90ExecuteImpl(ApiSets.Select(item => (item.ItemSpec, (IReadOnlyList<string>)File.ReadAllLines(item.ItemSpec)))); 116var peImageBuffer = File.ReadAllBytes(originalReferencePath); 122File.WriteAllBytes(filteredReferencePath, peImageBuffer); 124catch when (File.Exists(filteredReferencePath)) 163if (File.Exists(outputFilePath)) 167oldContent = File.ReadAllText(outputFilePath, Encoding.UTF8); 191File.WriteAllText(outputFilePath, newContent, Encoding.UTF8);
ServerComparison.FunctionalTests (1)
Helpers.cs (1)
35var content = File.ReadAllText(Path.Combine(applicationBasePath, nginxConfig));
Sockets.FunctionalTests (1)
src\Servers\Kestrel\test\FunctionalTests\UnixDomainSocketsTests.cs (1)
207File.Delete(path);
Stress.ApiService (2)
Program.cs (2)
294var xmlLarge = File.ReadAllText(Path.Combine("content", "books.xml")); 301var jsonLarge = File.ReadAllText(Path.Combine("content", "example.json"));
Swaggatherer (3)
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
SwaggathererApplication.cs (2)
121File.WriteAllText(Output.Value(), text); 127using (var reader = File.OpenText(input))
System.CodeDom (5)
Microsoft\CSharp\CSharpCodeGenerator.cs (2)
2955File.OpenRead(fileName).Dispose(); 2995File.OpenRead(fileName).Dispose();
src\libraries\Common\src\System\IO\TempFileCollection.cs (1)
186File.Delete(fileName);
System\CodeDom\Compiler\CodeCompiler.cs (2)
77File.OpenRead(fileName).Dispose(); 119File.OpenRead(fileName).Dispose();
System.ComponentModel.TypeConverter (1)
System\ComponentModel\LicFileLicenseProvider.cs (1)
85if (File.Exists(licenseFile))
System.Configuration.ConfigurationManager (21)
src\libraries\Common\src\System\IO\TempFileCollection.cs (1)
186File.Delete(fileName);
System\Configuration\AppSettingsSection.cs (1)
104if (!IO.File.Exists(sourceFileFullPath)) return;
System\Configuration\ClientConfigPaths.cs (1)
47if (!File.Exists(ApplicationUri))
System\Configuration\ConfigurationFileMap.cs (1)
30if (!File.Exists(machineConfigFilename))
System\Configuration\Internal\InternalConfigHost.cs (3)
227return !File.Exists(streamName) 253if (File.Exists(streamName)) 293File.Delete(streamName);
System\Configuration\Internal\WriteFileContext.cs (12)
65if (File.Exists(filename)) 101FileAttributes attributes = File.GetAttributes(source); 102File.SetAttributes(destination, attributes); 105creationTime = File.GetCreationTimeUtc(source); 106File.SetCreationTimeUtc(destination, creationTime); 116FileAttributes fileAttributes = File.GetAttributes(source); 117File.SetAttributes(destination, fileAttributes); 169File.Exists(target) && 188if (File.Exists(target)) 190File.Replace(source, target, null); 194File.Move(source, target); 208if (!File.Exists(fileName))
System\Configuration\LocalFileSettingsProvider.cs (1)
330if (File.Exists(file))
System\Configuration\NameValueFileSectionHandler.cs (1)
43if (File.Exists(sourceFileFullPath))
System.Diagnostics.FileVersionInfo (2)
System\Diagnostics\FileVersionInfo.cs (1)
274if (!File.Exists(fileName))
System\Diagnostics\FileVersionInfo.Unix.cs (1)
49using (FileStream assemblyStream = File.OpenRead(_fileName))
System.Diagnostics.Process (12)
src\libraries\Common\src\Interop\Linux\cgroups\Interop.cgroups.cs (5)
72foreach (string line in File.ReadLines(path + "/memory.stat")) 154if (File.Exists(path)) 158byte[] bytes = File.ReadAllBytes(path); 314if (File.Exists(mountInfoFilePath)) 384if (File.Exists(procCGroupFilePath))
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcFsStat.ParseMapModules.cs (1)
26return ParseMapsModulesCore(File.ReadLines(GetMapsFilePathForProcess(pid)));
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.cs (1)
18if (File.Exists(ProcMountInfoFilePath))
System\Diagnostics\Process.Unix.cs (5)
637if (File.Exists(filename)) 645if (uri.IsFile && uri.Host == "" && File.Exists(uri.LocalPath)) 659if (File.Exists(filenameInWorkingDirectory)) 713if (File.Exists(path)) 723if (File.Exists(path))
System.Diagnostics.StackTrace (1)
System\Diagnostics\StackTraceSymbols.cs (1)
225if (!File.Exists(path))
System.Diagnostics.TraceSource (1)
System\Diagnostics\DefaultTraceListener.cs (1)
165File.AppendAllText(LogFileName!, message);
System.Drawing.Common (6)
System\Drawing\Icon.cs (1)
158if (!File.Exists(filePath))
System\Drawing\Image.cs (3)
88if (!File.Exists(filename)) 268using var fs = File.OpenWrite(filename); 922created = dataStream = File.OpenRead(filename ?? throw new InvalidOperationException());
System\Drawing\Text\PrivateFontCollection.cs (1)
53if (!File.Exists(filename))
System\Drawing\ToolboxBitmapAttribute.cs (1)
157using FileStream reader = File.OpenRead(imageFile!);
System.Drawing.Common.Tests (57)
mono\System.Drawing.Imaging\BmpCodecTests.cs (1)
457File.Delete(sOutFile);
mono\System.Drawing.Imaging\GifCodecTests.cs (1)
221File.Delete(sOutFile);
mono\System.Drawing.Imaging\IconCodecTests.cs (1)
1898File.Delete(sOutFile);
mono\System.Drawing.Imaging\JpegCodecTests.cs (1)
379File.Delete(sOutFile);
mono\System.Drawing.Imaging\PngCodecTests.cs (1)
597File.Delete(sOutFile);
mono\System.Drawing.Imaging\TiffCodecTests.cs (1)
268File.Delete(sOutFile);
mono\System.Drawing\BitmapTests.cs (1)
791File.Delete(filename);
mono\System.Imaging\MetafileTest.cs (4)
108using FileStream fs = File.OpenRead(Helpers.GetTestBitmapPath(WmfPlaceable)); 124using MemoryStream ms = new(File.ReadAllBytes(filename)); 169using FileStream fs = File.OpenRead(Helpers.GetTestBitmapPath(Emf)); 179using MemoryStream ms = new(File.ReadAllBytes(filename));
System\Drawing\BitmapTests.cs (5)
119using Stream stream = File.OpenRead(Helpers.GetTestBitmapPath(filename)); 133using Stream stream = File.OpenRead(Helpers.GetTestBitmapPath(filename)); 739using Stream wmfStream = File.OpenRead(Helpers.GetTestBitmapPath("gdiwmfboundariesbug.wmf")); 743using Stream expectedPngStream = File.OpenRead(Helpers.GetTestBitmapPath("gdiwmfboundariesbug-output.png")); 746using Stream outputPngStream = File.OpenRead(output);
System\Drawing\IconTests.cs (8)
97using var stream = File.OpenRead(Helpers.GetTestBitmapPath("48x48_multiple_entries_4bit.ico")); 107TrickleStream stream = new(File.ReadAllBytes(Helpers.GetTestBitmapPath("48x48_multiple_entries_4bit.ico"))); 124using var stream = File.OpenRead(Helpers.GetTestBitmapPath(fileName)); 135using var stream = File.OpenRead(Helpers.GetTestBitmapPath(fileName)); 365File.Open(bitmapUncPath, FileMode.Open, FileAccess.Read, FileShare.Read).Dispose(); 435Assert.Equal(File.ReadAllBytes(filePath), outputStream.ToArray()); 446Assert.Equal(File.ReadAllBytes(filePath), outputStream.ToArray()); 750using var stream = File.OpenRead(Helpers.GetTestBitmapPath("pngwithheight_icon.ico"));
System\Drawing\ImageConverterTests.cs (1)
50using FileStream fileStream = File.Open(path, FileMode.Open);
System\Drawing\Imaging\MetafileTests.cs (30)
96using FileStream stream = File.OpenRead(GetPath(WmfFile)); 345Assert.True(File.Exists(fileName)); 348File.Delete(fileName); 362Assert.True(File.Exists(fileName)); 365File.Delete(fileName); 379Assert.True(File.Exists(fileName)); 382File.Delete(fileName); 454Assert.True(File.Exists(fileName)); 457File.Delete(fileName); 470Assert.True(File.Exists(fileName)); 473File.Delete(fileName); 487Assert.True(File.Exists(fileName)); 490File.Delete(fileName); 505Assert.True(File.Exists(fileName)); 508File.Delete(fileName); 523Assert.True(File.Exists(fileName)); 526File.Delete(fileName); 538Assert.True(File.Exists(fileName)); 541File.Delete(fileName); 554Assert.True(File.Exists(fileName)); 557File.Delete(fileName); 571Assert.True(File.Exists(fileName)); 574File.Delete(fileName); 589Assert.True(File.Exists(fileName)); 592File.Delete(fileName); 607Assert.True(File.Exists(fileName)); 610File.Delete(fileName); 870using FileStream stream = File.OpenRead(GetPath(WmfFile)); 935if (File.Exists(path)) 937File.Delete(path);
System\Drawing\Text\PrivateFontCollectionTests.cs (2)
138byte[] data = File.ReadAllBytes(Helpers.GetTestFontPath("CodeNewRoman.otf")); 174byte[] data = File.ReadAllBytes(Helpers.GetTestFontPath("CodeNewRoman.otf"));
System.Formats.Tar (11)
src\libraries\Common\src\System\IO\Archiving.Utils.cs (1)
39File.SetLastWriteTime(destinationFileName, lastWriteTime.DateTime);
System\Formats\Tar\TarEntry.cs (3)
187/// <para>Symbolic links can be recreated using <see cref="File.CreateSymbolicLink(string, string)"/>, <see cref="Directory.CreateSymbolicLink(string, string)"/> or <see cref="FileSystemInfo.CreateAsSymbolicLink(string)"/>.</para> 528File.Delete(filePath); 573File.SetLastWriteTime(destinationFileName, lastWriteTime.UtcDateTime);
System\Formats\Tar\TarEntry.Unix.cs (1)
40File.CreateHardLink(hardLinkFilePath, targetFilePath);
System\Formats\Tar\TarFile.cs (3)
264if (!File.Exists(sourceFileName)) 274using FileStream archive = File.OpenRead(sourceFileName); 311if (!File.Exists(sourceFileName))
System\Formats\Tar\TarHelpers.Unix.cs (3)
35UnixFileMode actual = File.GetUnixFileMode(fs.SafeFileHandle); 74File.SetUnixFileMode(fullPath, mode.Value & ~umask); 114File.SetUnixFileMode(dir.Key, dir.Value & ~umask);
System.IO.Compression.ZipFile (2)
src\libraries\Common\src\System\IO\Archiving.Utils.cs (1)
39File.SetLastWriteTime(destinationFileName, lastWriteTime.DateTime);
System\IO\Compression\ZipFileExtensions.ZipArchive.Create.cs (1)
113DateTime lastWrite = File.GetLastWriteTime(sourceFileName);
System.IO.FileSystem (1)
System.IO.FileSystem.cs (1)
10[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.File))]
System.IO.FileSystem.DriveInfo (2)
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.cs (1)
18if (File.Exists(ProcMountInfoFilePath))
src\libraries\Common\src\Interop\Unix\System.Native\Interop.MountPoints.cs (1)
44if (File.Exists(Interop.procfs.ProcMountInfoFilePath))
System.IO.FileSystem.Watcher (1)
System\IO\FileSystemWatcher.Linux.cs (1)
146try { return File.ReadAllText(path).Trim(); }
System.IO.IsolatedStorage (7)
System\IO\IsolatedStorage\IsolatedStorageFile.cs (7)
83File.Delete(fullPath); 97return File.Exists(GetFullPath(path)); 243return new DateTimeOffset(File.GetCreationTime(GetFullPath(path))); 259return new DateTimeOffset(File.GetLastAccessTime(GetFullPath(path))); 275return new DateTimeOffset(File.GetLastWriteTime(GetFullPath(path))); 303File.Copy(sourceFileNameFullPath, destinationFileNameFullPath, overwrite); 331File.Move(sourceFileNameFullPath, destinationFileNameFullPath);
System.IO.MemoryMappedFiles (4)
System\IO\MemoryMappedFiles\MemoryMappedFile.cs (3)
125_ => File.Exists(path) 127SafeFileHandle fileHandle = File.OpenHandle(path, mode, GetFileAccess(access), FileShare.Read, FileOptions.None); 511File.Delete(path);
System\IO\MemoryMappedFiles\MemoryMappedFile.Unix.cs (1)
324SafeFileHandle fileHandle = File.OpenHandle(path, FileMode.CreateNew, TranslateProtectionsToFileAccess(protections), share);
System.IO.Ports (3)
System\IO\Ports\SerialPort.Unix.cs (3)
56(File.Exists(entry.FullName + "/device/id") || 60(isTtyGS && (File.Exists(entry.FullName + "/dev")))) 63if (File.Exists(deviceName))
System.Memory.Data (2)
System\BinaryData.cs (2)
328return new BinaryData(File.ReadAllBytes(path), mediaType); 360await File.ReadAllBytesAsync(path, cancellationToken).ConfigureAwait(false),
System.Net.Mail (1)
System\Net\Mail\SmtpClient.cs (1)
372if (!File.Exists(pathAndFilename))
System.Net.NetworkInformation (11)
System\Net\NetworkInformation\LinuxNetworkInterface.cs (5)
33if (File.Exists(NetworkFiles.Ipv4RouteFile)) 37IPv4Routes = File.ReadAllLines(NetworkFiles.Ipv4RouteFile); 44if (File.Exists(NetworkFiles.Ipv6RouteFile)) 48IPv6Routes = File.ReadAllLines(NetworkFiles.Ipv6RouteFile); 57string resolverConfig = File.ReadAllText(NetworkFiles.EtcResolvConfFile);
System\Net\NetworkInformation\StringParsingHelpers.Addresses.cs (2)
87if (File.Exists(filePath)) // avoid an exception in most cases if path doesn't already exist 129if (File.Exists(smbConfFilePath)) // avoid an exception in most cases if path doesn't already exist
System\Net\NetworkInformation\StringParsingHelpers.Misc.cs (2)
19return File.ReadAllLines(filePath); 31return File.ReadAllText(filePath);
System\Net\NetworkInformation\UnixIPInterfaceProperties.cs (2)
91return StringParsingHelpers.ParseDnsSuffixFromResolvConfFile(File.ReadAllText(NetworkFiles.EtcResolvConfFile)); 103List<IPAddress> internalAddresses = StringParsingHelpers.ParseDnsAddressesFromResolvConfFile(File.ReadAllText(NetworkFiles.EtcResolvConfFile));
System.Net.Ping (3)
src\libraries\Common\src\System\Net\NetworkInformation\UnixCommandLinePing.cs (3)
32if (File.Exists(path)) 36if (File.Exists(pathv4v6)) 50System.IO.FileSystemInfo? linkInfo = File.ResolveLinkTarget(pingBinary, returnFinalTarget: true);
System.Net.Quic (1)
src\libraries\Common\src\System\Net\Security\SslKeyLogger.cs (1)
29s_fileStream = File.Open(s_keyLogFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
System.Net.Security (1)
src\libraries\Common\src\System\Net\Security\SslKeyLogger.cs (1)
29s_fileStream = File.Open(s_keyLogFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
System.Net.Sockets (3)
System\Net\Sockets\Socket.cs (2)
3519File.Delete(unixEndPoint.BoundFileName); 3990private static SafeFileHandle? OpenFileHandle(string? name) => string.IsNullOrEmpty(name) ? null : File.OpenHandle(name, FileMode.Open, FileAccess.Read);
System\Net\Sockets\SocketAsyncEventArgs.Unix.cs (1)
259fileHandles[i] = File.OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.Read, FileOptions.Asynchronous);
System.Net.WebClient (1)
System\Net\WebClient.cs (1)
351File.Delete(fileName);
System.Private.CoreLib (35)
src\libraries\Common\src\Interop\Linux\os-release\Interop.OSReleaseFile.cs (2)
19if (File.Exists(filename)) 24lines = File.ReadAllLines(filename);
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.cs (1)
18if (File.Exists(ProcMountInfoFilePath))
src\libraries\Common\src\Interop\Unix\System.Native\Interop.MountPoints.cs (1)
44if (File.Exists(Interop.procfs.ProcMountInfoFilePath))
src\libraries\System.Private.CoreLib\src\System\IO\Directory.cs (9)
109FileSystem.SetCreationTime(fullPath, File.GetUtcDateTimeOffset(creationTimeUtc), asDirectory: true); 114return File.GetCreationTime(path); 119return File.GetCreationTimeUtc(path); 131FileSystem.SetLastWriteTime(fullPath, File.GetUtcDateTimeOffset(lastWriteTimeUtc), asDirectory: true); 136return File.GetLastWriteTime(path); 141return File.GetLastWriteTimeUtc(path); 153FileSystem.SetLastAccessTime(fullPath, File.GetUtcDateTimeOffset(lastAccessTimeUtc), asDirectory: true); 158return File.GetLastAccessTime(path); 163return File.GetLastAccessTimeUtc(path);
src\libraries\System.Private.CoreLib\src\System\IO\File.cs (1)
563/// It is not possible to change the compression status of a <see cref="File"/> object
src\libraries\System.Private.CoreLib\src\System\IO\FileInfo.cs (5)
78public FileStream Open(FileStreamOptions options) => File.Open(NormalizedPath, options); 102FileStream fileStream = File.Create(NormalizedPath); 138=> new FileStream(NormalizedPath, FileMode.Open, FileAccess.Read, FileShare.Read, File.DefaultBufferSize, false); 196public void Decrypt() => File.Decrypt(FullPath); 199public void Encrypt() => File.Encrypt(FullPath);
src\libraries\System.Private.CoreLib\src\System\IO\FileSystemInfo.cs (3)
81set => CreationTimeCore = File.GetUtcDateTimeOffset(value); 93set => LastAccessTimeCore = File.GetUtcDateTimeOffset(value); 105set => LastWriteTimeCore = File.GetUtcDateTimeOffset(value);
src\libraries\System.Private.CoreLib\src\System\IO\Path.cs (1)
82/// Unlike <see cref="File.Exists(string?)"/> it returns true for existing, non-regular files like pipes.
src\libraries\System.Private.CoreLib\src\System\IO\SharedMemoryManager.Unix.cs (1)
403if (File.Exists(sharedFilesPath))
src\libraries\System.Private.CoreLib\src\System\Reflection\Assembly.cs (2)
291if (!File.Exists(normalizedPath)) 357if (!File.Exists(requestedAssemblyPath))
src\libraries\System.Private.CoreLib\src\System\Resources\FileBasedResourceGroveler.cs (2)
72if (File.Exists(path)) 79if (File.Exists(fileName))
src\libraries\System.Private.CoreLib\src\System\Runtime\Loader\AssemblyDependencyResolver.cs (3)
134if (File.Exists(assemblyPath)) 148if (File.Exists(assemblyPath)) 182if (File.Exists(libraryPath))
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.Unix.NonAndroid.cs (4)
37using FileStream fs = File.OpenRead(path); 268using (SafeFileHandle sfh = File.OpenHandle(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) 353if (File.Exists(tzFilePath)) 357rawData = File.ReadAllBytes(tzFilePath);
System.Private.Windows.Core.TestUtilities (5)
TempFile.cs (5)
33File.WriteAllBytes(path, data); 41File.WriteAllText(path, text); 64public void AssertExists() => Assert.True(File.Exists(Path)); 66public string ReadAllText() => File.ReadAllText(Path); 77{ File.Delete(Path); }
System.Private.Xml (3)
System\Xml\Serialization\Compilation.cs (2)
239if ((string.IsNullOrEmpty(path) || !File.Exists(path)) && !string.IsNullOrEmpty(Assembly.GetEntryAssembly()?.Location)) 244if ((string.IsNullOrEmpty(path) || !File.Exists(path)) && !string.IsNullOrEmpty(AppContext.BaseDirectory))
System\Xml\Xsl\IlGen\XmlILTrace.cs (1)
67File.Delete(s_dirName + "\\" + fileName);
System.Reflection.MetadataLoadContext (3)
System\Reflection\MetadataLoadContext.Apis.cs (1)
133return LoadFromStreamCore(File.OpenRead(assemblyPath));
System\Reflection\TypeLoading\Assemblies\Ecma\EcmaAssembly.Modules.cs (2)
46if (File.Exists(modulePath)) 47return File.OpenRead(modulePath);
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net11.0\System.Runtime.Forwards.cs (1)
301[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.File))]
System.Runtime.Caching (1)
System\Runtime\Caching\FileChangeNotificationSystem.cs (1)
137lastWriteTime = File.GetLastWriteTime(filePath);
System.Security.Cryptography (15)
src\libraries\Common\src\System\Security\Cryptography\X509Certificates\X509CertificateLoader.cs (1)
593using (FileStream stream = File.OpenRead(path))
System\Security\Cryptography\X509Certificates\OpenSslCrlCache.cs (1)
147nextUpdate = File.GetLastWriteTime(crlFile).AddDays(3);
System\Security\Cryptography\X509Certificates\OpenSslDirectoryBasedStoreProvider.cs (5)
196File.SetUnixFileMode(existingFilename, UserReadWrite); 213UnixFileMode actualMode = File.GetUnixFileMode(stream.SafeFileHandle); 249File.Delete(currentFilename); 310if (!File.Exists(builtPath)) 380UnixFileMode permissions = File.GetUnixFileMode(path);
System\Security\Cryptography\X509Certificates\X509Certificate2.cs (6)
1225/// See <see cref="System.IO.File.ReadAllText(string)" /> for additional documentation about 1251ReadOnlySpan<char> certContents = File.ReadAllText(certPemFilePath); 1252ReadOnlySpan<char> keyContents = keyPemFilePath is null ? certContents : File.ReadAllText(keyPemFilePath); 1294/// See <see cref="System.IO.File.ReadAllText(string)" /> for additional documentation about 1317ReadOnlySpan<char> certContents = File.ReadAllText(certPemFilePath); 1318ReadOnlySpan<char> keyContents = keyPemFilePath is null ? certContents : File.ReadAllText(keyPemFilePath);
System\Security\Cryptography\X509Certificates\X509Certificate2Collection.cs (2)
392/// See <see cref="System.IO.File.ReadAllText(string)" /> for additional documentation about 415ReadOnlySpan<char> contents = System.IO.File.ReadAllText(certPemFilePath);
System.Windows.Forms (6)
System\Windows\Forms\Controls\PictureBox\PictureBox.cs (1)
572_fileStream = File.OpenRead(_imageLocation!);
System\Windows\Forms\Controls\RichTextBox\RichTextBox.cs (1)
2622FileStream file = File.Create(path);
System\Windows\Forms\Dialogs\CommonDialogs\FileDialog.cs (1)
445return File.Exists(fileName);
System\Windows\Forms\Help\Help.cs (2)
256if (!File.Exists(localPath)) 279if (!File.Exists(localPath))
System\Windows\Forms\Input\Cursor.cs (1)
73_cursorData = File.ReadAllBytes(fileName);
System.Windows.Forms.Analyzers.CSharp.Tests (2)
Analyzers\AvoidPassingTaskWithoutCancellationToken\AvoidPassingTaskWithoutCancellationTokenTest.cs (1)
102Assert.True(pathToWinFormsAssembly == "" || File.Exists(pathToWinFormsAssembly));
Analyzers\WFO1001\ImplementITypedDataObjectTests.cs (1)
144Assert.True(File.Exists(CurrentReferences.WinFormsRefPath));
System.Windows.Forms.Analyzers.Tests (3)
CurrentReferences.cs (3)
124if (File.Exists(globalJsonPath)) 141string globalJsonString = File.ReadAllText(globalJsonPath); 154string configJsonString = File.ReadAllText(configJsonPath);
System.Windows.Forms.Design (2)
System\ComponentModel\Design\ByteViewer.cs (1)
672SetBytes(File.ReadAllBytes(path));
System\Drawing\BitmapSelector.cs (1)
50return File.Exists(newPath) ? newPath : originalPath;
System.Windows.Forms.Design.Tests (5)
System\ComponentModel\Design\ByteViewerTests.cs (2)
601Assert.Equal(new byte[] { 1, 2, 3 }, File.ReadAllBytes(path)); 605File.Delete(path);
System\Drawing\Design\BitmapEditorTests.cs (1)
90using Stream stream = File.OpenRead("Resources/telescope_01.wmf");
System\Drawing\Design\ImageEditorTests.cs (1)
147using Stream stream = File.OpenRead("Resources/telescope_01.wmf");
System\Drawing\Design\MetafileEditorTests.cs (1)
69using Stream stream = File.OpenRead("Resources/telescope_01.wmf");
System.Windows.Forms.IntegrationTests.Common (4)
TestHelpers.cs (4)
62if (!File.Exists(exePath)) 82if (!File.Exists(path)) 186if (!File.Exists(jsonFile)) 190string jsonContents = File.ReadAllText(jsonFile);
System.Windows.Forms.Primitives (1)
System\Windows\Forms\Internals\ThemingScope.cs (1)
114File.Delete(tempFilePath);
System.Windows.Forms.Primitives.TestUtilities (2)
Metafiles\EmfValidateHelper.cs (1)
32File.AppendAllText(@$"c:\temp\{methodName}.md", sb.ToString());
PlatformDetection.Windows.cs (1)
55File.Exists(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "System32", "httpapi.dll"));
System.Windows.Forms.Tests (13)
System\Resources\ResXResourceSetTests.cs (2)
21Assert.True(File.Exists(resxFileName), $@"RESX file ""{resxFileName}"" not found, make sure it's in the root folder of the unit test project"); 41Assert.True(File.Exists(resxFileName), $@"RESX file ""{resxFileName}"" not found, make sure it's in the root folder of the unit test project");
System\Windows\Forms\CursorConverterTests.cs (3)
39byte[] data = File.ReadAllBytes(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); 129byte[] data = File.ReadAllBytes(Path.Join("bitmaps", "10x16_one_entry_32bit.ico")); 140byte[] data = File.ReadAllBytes(fileName);
System\Windows\Forms\CursorTests.cs (3)
68using MemoryStream stream = new(File.ReadAllBytes(fileName)); 79using MemoryStream stream = new(File.ReadAllBytes(Path.Join("bitmaps", "cursor.cur"))); 112using MemoryStream stream = new(File.ReadAllBytes(fileName));
System\Windows\Forms\RichTextBoxTests.cs (3)
10697File.Delete(filePath); 10717File.Exists(filePath).Should().BeTrue(); 10721File.Delete(filePath);
System\Windows\Forms\UserConfigDisposableFixture.cs (2)
25if (File.Exists(configuration.FilePath)) 27File.Delete(configuration.FilePath);
System.Windows.Forms.UI.IntegrationTests (10)
DragDropTests.cs (9)
149if (!File.Exists(dragAcceptRtfDestPath)) 151File.Copy(dragAcceptRtfSourcePath, dragAcceptRtfDestPath); 159richTextBox.Rtf = File.ReadAllText(dragAcceptRtfDestPath); 237if (File.Exists(dragAcceptRtfDestPath)) 239File.Delete(dragAcceptRtfDestPath); 427richTextBox.Rtf = File.ReadAllText(dragAcceptRtfPath); 457richTextBox.Rtf = File.ReadAllText(dragAcceptRtfPath); 1085if (File.Exists(dragAcceptRtf)) 1145if (File.Exists(dragAcceptRtf))
Infra\DataCollectionService.cs (1)
171File.WriteAllText(CreateLogFileName(logDir, timestamp, testName, errorId, logId: string.Empty, "log"), exceptionDetails.ToString());
Templates.Blazor.Tests (40)
BlazorWasmTemplateTest.cs (6)
30Assert.False(File.Exists(Path.Combine(publishDir, "service-worker-assets.js")), "Non-PWA templates should not produce service-worker-assets.js"); 109Assert.False(File.Exists(Path.Combine(publishDir, "service-worker.published.js")), "service-worker.published.js should not be published"); 110Assert.True(File.Exists(Path.Combine(publishDir, "service-worker.js")), "service-worker.js should be published"); 111Assert.True(File.Exists(Path.Combine(publishDir, "service-worker-assets.js")), "service-worker-assets.js should be published"); 128var doesExist = File.Exists(fullPath); 131return File.ReadAllText(Path.Combine(basePath, path));
src\ProjectTemplates\Shared\BlazorTemplateTest.cs (2)
108var doesExist = File.Exists(fullPath); 111return File.ReadAllText(Path.Combine(basePath, path));
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (3)
26using var file = File.OpenRead(json); 32if (!File.Exists(path)) 47if (File.Exists(location))
src\ProjectTemplates\Shared\Project.cs (7)
274var contents = File.ReadAllText(file); 300var doesExist = File.Exists(fullPath); 318using var launchSettingsFile = File.OpenRead(filePath); 359var projectFileContents = await File.ReadAllTextAsync(projectFile); 411return File.ReadAllText(Path.Combine(TemplateOutputDir, path)); 534Assert.True(File.Exists(sourceFile), $"Log for '{ProjectName}' not found in '{sourceFile}'. Execution output: {result.Output}"); 536File.Move(sourceFile, destination, overwrite: true); // binlog will exist on retries
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
Templates.Blazor.WebAssembly.Auth.Tests (38)
src\ProjectTemplates\Shared\BlazorTemplateTest.cs (2)
108var doesExist = File.Exists(fullPath); 111return File.ReadAllText(Path.Combine(basePath, path));
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (3)
26using var file = File.OpenRead(json); 32if (!File.Exists(path)) 47if (File.Exists(location))
src\ProjectTemplates\Shared\Project.cs (7)
274var contents = File.ReadAllText(file); 300var doesExist = File.Exists(fullPath); 318using var launchSettingsFile = File.OpenRead(filePath); 359var projectFileContents = await File.ReadAllTextAsync(projectFile); 411return File.ReadAllText(Path.Combine(TemplateOutputDir, path)); 534Assert.True(File.Exists(sourceFile), $"Log for '{ProjectName}' not found in '{sourceFile}'. Execution output: {result.Output}"); 536File.Move(sourceFile, destination, overwrite: true); // binlog will exist on retries
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\Shared\E2ETesting\BrowserAssertFailedException.cs (1)
27if (File.Exists(screenShotPath))
src\Shared\E2ETesting\SauceConnectServer.cs (3)
222if (pidFilePath != null && File.Exists(pidFilePath)) 224File.Delete(pidFilePath); 240await File.WriteAllTextAsync(pidFile, process.Id.ToString(CultureInfo.InvariantCulture));
Templates.Blazor.WebAssembly.Tests (42)
BlazorWasmTemplateTest.cs (4)
36Assert.False(File.Exists(Path.Combine(publishDir, "service-worker-assets.js")), "Non-PWA templates should not produce service-worker-assets.js"); 46Assert.False(File.Exists(Path.Combine(publishDir, "service-worker-assets.js")), "Non-PWA templates should not produce service-worker-assets.js"); 56Assert.False(File.Exists(Path.Combine(publishDir, "service-worker-assets.js")), "Non-PWA templates should not produce service-worker-assets.js"); 66Assert.False(File.Exists(Path.Combine(publishDir, "service-worker-assets.js")), "Non-PWA templates should not produce service-worker-assets.js");
src\ProjectTemplates\Shared\BlazorTemplateTest.cs (2)
108var doesExist = File.Exists(fullPath); 111return File.ReadAllText(Path.Combine(basePath, path));
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (3)
26using var file = File.OpenRead(json); 32if (!File.Exists(path)) 47if (File.Exists(location))
src\ProjectTemplates\Shared\Project.cs (7)
274var contents = File.ReadAllText(file); 300var doesExist = File.Exists(fullPath); 318using var launchSettingsFile = File.OpenRead(filePath); 359var projectFileContents = await File.ReadAllTextAsync(projectFile); 411return File.ReadAllText(Path.Combine(TemplateOutputDir, path)); 534Assert.True(File.Exists(sourceFile), $"Log for '{ProjectName}' not found in '{sourceFile}'. Execution output: {result.Output}"); 536File.Move(sourceFile, destination, overwrite: true); // binlog will exist on retries
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\Shared\E2ETesting\BrowserAssertFailedException.cs (1)
27if (File.Exists(screenShotPath))
src\Shared\E2ETesting\SauceConnectServer.cs (3)
222if (pidFilePath != null && File.Exists(pidFilePath)) 224File.Delete(pidFilePath); 240await File.WriteAllTextAsync(pidFile, process.Id.ToString(CultureInfo.InvariantCulture));
Templates.Mvc.Tests (46)
BlazorTemplateTest.cs (6)
177if (File.Exists(singleProjectPath)) 179return File.ReadAllTextAsync(singleProjectPath); 183if (File.Exists(multiProjectPath)) 187return File.ReadAllTextAsync(multiProjectPath); 196var appRazorText = await File.ReadAllTextAsync(appRazorPath); 198await File.WriteAllTextAsync(appRazorPath, appRazorText);
RazorPagesTemplateTest.cs (2)
311var doesExist = File.Exists(fullPath); 314return File.ReadAllText(Path.Combine(basePath, path));
src\ProjectTemplates\Shared\BlazorTemplateTest.cs (2)
108var doesExist = File.Exists(fullPath); 111return File.ReadAllText(Path.Combine(basePath, path));
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (3)
26using var file = File.OpenRead(json); 32if (!File.Exists(path)) 47if (File.Exists(location))
src\ProjectTemplates\Shared\Project.cs (7)
274var contents = File.ReadAllText(file); 300var doesExist = File.Exists(fullPath); 318using var launchSettingsFile = File.OpenRead(filePath); 359var projectFileContents = await File.ReadAllTextAsync(projectFile); 411return File.ReadAllText(Path.Combine(TemplateOutputDir, path)); 534Assert.True(File.Exists(sourceFile), $"Log for '{ProjectName}' not found in '{sourceFile}'. Execution output: {result.Output}"); 536File.Move(sourceFile, destination, overwrite: true); // binlog will exist on retries
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\Shared\E2ETesting\BrowserAssertFailedException.cs (1)
27if (File.Exists(screenShotPath))
src\Shared\E2ETesting\SauceConnectServer.cs (3)
222if (pidFilePath != null && File.Exists(pidFilePath)) 224File.Delete(pidFilePath); 240await File.WriteAllTextAsync(pidFile, process.Id.ToString(CultureInfo.InvariantCulture));
Templates.Tests (42)
BaselineTest.cs (2)
109var namespaceDeclaration = File.ReadLines(file) 125var doesExist = File.Exists(fullPath);
IdentityUIPackageTest.cs (2)
162var doesExist = File.Exists(fullPath); 165return File.ReadAllText(Path.Combine(basePath, path));
src\ProjectTemplates\Shared\BlazorTemplateTest.cs (2)
108var doesExist = File.Exists(fullPath); 111return File.ReadAllText(Path.Combine(basePath, path));
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (3)
26using var file = File.OpenRead(json); 32if (!File.Exists(path)) 47if (File.Exists(location))
src\ProjectTemplates\Shared\Project.cs (7)
274var contents = File.ReadAllText(file); 300var doesExist = File.Exists(fullPath); 318using var launchSettingsFile = File.OpenRead(filePath); 359var projectFileContents = await File.ReadAllTextAsync(projectFile); 411return File.ReadAllText(Path.Combine(TemplateOutputDir, path)); 534Assert.True(File.Exists(sourceFile), $"Log for '{ProjectName}' not found in '{sourceFile}'. Execution output: {result.Output}"); 536File.Move(sourceFile, destination, overwrite: true); // binlog will exist on retries
src\Shared\CertificateGeneration\CertificateManager.cs (5)
445if (!File.Exists(certificatePath)) 646File.Move(tempFilename, path, overwrite: true); 649File.WriteAllBytes(path, bytes); 674File.Move(tempFilename, keyPath, overwrite: true); 677File.WriteAllBytes(keyPath, pemEnvelope);
src\Shared\CertificateGeneration\MacOSCertificateManager.cs (9)
120File.Delete(tmpFile); 131return File.Exists(GetCertificateFilePath(candidate)) ? 173File.Delete(tmpFile); 205File.WriteAllBytes(certificatePath, certBytes); 228File.Delete(certificatePath); 323File.WriteAllBytes(GetCertificateFilePath(certificate), certBytes); 343File.WriteAllBytes(certificatePath, certBytes); 464if (File.Exists(certificatePath)) 466File.Delete(certificatePath);
src\Shared\CertificateGeneration\UnixCertificateManager.cs (7)
109if (File.Exists(certPath)) 241if (File.Exists(certPath)) 402if (File.Exists(certPath)) 539if (File.Exists(Path.Combine(searchFolder, command))) 691File.Delete(certPath); 926if (!File.Exists(linkPath)) 929File.CreateSymbolicLink(linkPath, cert.Name);
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
src\Shared\E2ETesting\BrowserAssertFailedException.cs (1)
27if (File.Exists(screenShotPath))
src\Shared\E2ETesting\SauceConnectServer.cs (3)
222if (pidFilePath != null && File.Exists(pidFilePath)) 224File.Delete(pidFilePath); 240await File.WriteAllTextAsync(pidFile, process.Id.ToString(CultureInfo.InvariantCulture));
Test.Utilities (4)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
TestTasks (3)
InjectRequestHandler.cs (3)
27using (var file = File.OpenText(depsFile)) 61File.Copy(Path.Combine(outputFolder, bitnessString, aspnetcoreV2Name), Path.Combine(outputFolder, aspnetcoreV2Name), overwrite: true); 81using (var file = File.CreateText(depsFile))
Text.Analyzers (5)
src\Compilers\Core\Portable\FileSystem\FileUtilities.cs (1)
399return File.GetLastWriteTimeUtc(fullPath);
src\Compilers\Core\Portable\FileSystem\RelativePathResolver.cs (1)
51return File.Exists(fullPath);
src\RoslynAnalyzers\Utilities\Compiler\RulesetToEditorconfigConverter.cs (2)
38File.WriteAllText(editorconfigFilePath, GetEditorconfig(rulesetFilePath)); 96using Stream stream = File.OpenRead(rulesetFilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Helpers\MefHostServicesHelpers.cs (1)
66if (File.Exists(potentialAssemblyPath))
vbc (6)
src\Compilers\Shared\BuildServerConnection.cs (4)
439if (!File.Exists(processFilePath)) 529if (!File.Exists(serverInfo.processFilePath)) 821if (!File.Exists(FilePath)) 851File.Delete(FilePath);
src\Compilers\Shared\RuntimeHostInfo.cs (2)
43var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 91if (File.Exists(filePath))
VBCSCompiler (7)
src\Compilers\Server\VBCSCompiler\AnalyzerConsistencyChecker.cs (1)
88string? resolvedPath = FileUtilities.ResolveRelativePath(analyzerReference.FilePath, basePath: null, baseDirectory: baseDirectory, searchPaths: SpecializedCollections.EmptyEnumerable<string>(), fileExists: File.Exists);
src\Compilers\Shared\BuildServerConnection.cs (4)
439if (!File.Exists(processFilePath)) 529if (!File.Exists(serverInfo.processFilePath)) 821if (!File.Exists(FilePath)) 851File.Delete(FilePath);
src\Compilers\Shared\RuntimeHostInfo.cs (2)
43var resolvedPath = File.ResolveLinkTarget(dotNetPath, returnFinalTarget: true); 91if (File.Exists(filePath))
VBCSCompiler.UnitTests (15)
AnalyzerConsistencyCheckerTests.cs (1)
150File.Delete(mvidAlpha1.Path);
CompilerServerTests.cs (12)
98File.WriteAllBytes(filePath, NetStandard20.Resources.netstandard); 210var bytes = File.ReadAllBytes(outFile); 217File.Delete(srcFile); 218File.Delete(outFile); 526Assert.False(File.Exists(Path.Combine(_tempDirectory.Path, "hello.exe"))); 556Assert.False(File.Exists(Path.Combine(_tempDirectory.Path, "hello.exe"))); 573Assert.False(File.Exists(Path.Combine(_tempDirectory.Path, "missingfile.exe"))); 591Assert.False(File.Exists(Path.Combine(_tempDirectory.Path, "hello.exe"))); 616Assert.False(File.Exists(Path.Combine(_tempDirectory.Path, "app.exe"))); 634Assert.False(File.Exists(Path.Combine(_tempDirectory.Path, "missingfile.exe"))); 663Assert.False(File.Exists(Path.Combine(_tempDirectory.Path, "hellovb.exe"))); 692Assert.False(File.Exists(Path.Combine(_tempDirectory.Path, "app.exe")));
TouchedFileLoggingTests.cs (2)
188File.ReadAllText(touchedReadPath).Trim()); 192File.ReadAllText(touchedWritesPath).Trim());
Wasm.Performance.ConsoleHost (1)
src\Shared\CommandLineUtils\Utilities\DotNetMuxer.cs (1)
78if (File.Exists(candidateDotNetExePath))
WindowsBase.Tests (2)
System\IO\Packaging\EncryptedPackageEnvelopeTests.cs (2)
42using var stream = File.OpenRead(path); 50using var stream = File.OpenRead(path);
WinFormsControlsTest (2)
DragDrop.cs (1)
410return File.ReadAllText(nyanCatAsciiPath);
RichTextBoxes.cs (1)
17richTextBox1.LoadFile(File.OpenRead(@"Data\example.rtf"), RichTextBoxStreamType.RichText);
WinShimmer (1)
Program.cs (1)
31if (!File.Exists(exePath))
xunit.console (11)
CommandLine.cs (2)
19fileExists = File.Exists; 118var rspLines = File.ReadAllLines(path);
common\AssemblyResolution\AssemblyHelper.cs (1)
31if (!File.Exists(assemblyFileName))
common\AssemblyResolution\Microsoft.DotNet.PlatformAbstractions\Native\PlatformApis.cs (2)
101if (File.Exists("/etc/os-release")) 103var lines = File.ReadAllLines("/etc/os-release");
common\AssemblyResolution\Microsoft.Extensions.DependencyModel\FileWrapper.cs (4)
13return File.Exists(path); 18return File.ReadAllText(path); 23return File.OpenRead(path); 41var emptyFile = File.Create(path);
ConsoleRunner.cs (1)
435if (string.IsNullOrWhiteSpace(fileName) || File.Exists(fileName))
Utility\TransformFactory.cs (1)
66using (var stream = File.Create(outputFileName))