{"id":20943232,"url":"https://github.com/testableio/system.io.abstractions.extensions","last_synced_at":"2025-05-14T00:32:29.435Z","repository":{"id":40570797,"uuid":"397190926","full_name":"TestableIO/System.IO.Abstractions.Extensions","owner":"TestableIO","description":"Convenience functionality on top of System.IO.Abstractions","archived":false,"fork":false,"pushed_at":"2025-05-10T23:17:18.000Z","size":101,"stargazers_count":24,"open_issues_count":8,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T00:21:38.048Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TestableIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-08-17T09:29:26.000Z","updated_at":"2025-03-21T14:14:07.000Z","dependencies_parsed_at":"2023-10-11T16:24:36.188Z","dependency_job_id":"20eb7d2e-3c8e-4274-8687-636300c4652f","html_url":"https://github.com/TestableIO/System.IO.Abstractions.Extensions","commit_stats":null,"previous_names":["system-io-abstractions/system.io.abstractions.extensions"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TestableIO%2FSystem.IO.Abstractions.Extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TestableIO%2FSystem.IO.Abstractions.Extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TestableIO%2FSystem.IO.Abstractions.Extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TestableIO%2FSystem.IO.Abstractions.Extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TestableIO","download_url":"https://codeload.github.com/TestableIO/System.IO.Abstractions.Extensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254046494,"owners_count":22005607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T23:34:49.964Z","updated_at":"2025-05-14T00:32:24.408Z","avatar_url":"https://github.com/TestableIO.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![System.IO.Abstractions.Extensions](https://socialify.git.ci/System-IO-Abstractions/System.IO.Abstractions.Extensions/image?description=1\u0026font=Source%20Code%20Pro\u0026forks=1\u0026issues=1\u0026pattern=Charlie%20Brown\u0026pulls=1\u0026stargazers=1\u0026theme=Dark)\n[![NuGet](https://img.shields.io/nuget/v/TestableIO.System.IO.Abstractions.Extensions.svg)](https://www.nuget.org/packages/TestableIO.System.IO.Abstractions.Extensions)\n![Continuous Integration](https://github.com/TestableIO/System.IO.Abstractions.Extensions/workflows/Continuous%20Integration/badge.svg)\n[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)\n\u003c!-- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/2e777fa545c94767acccd6345b1ed9b7)](https://app.codacy.com/gh/TestableIO/System.IO.Abstractions.Extensions?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=TestableIO/System.IO.Abstractions.Extensions\u0026utm_campaign=Badge_Grade_Dashboard) --\u003e\n\u003c!-- [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FTestableIO%2FSystem.IO.Abstractions.Extensions.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FTestableIO%2FSystem.IO.Abstractions.Extensions?ref=badge_shield) --\u003e\n\nConvenience functionality on top of System.IO.Abstractions\n\n```shell\ndotnet add package TestableIO.System.IO.Abstractions.Extensions\n```\n\n# Examples\n\n## CurrentDirectory extension\n\n```csharp\nvar fs = new FileSystem();\n\n//with extension\nvar current = fs.CurrentDirectory();\n\n//without extension\nvar current =  fs.DirectoryInfo.FromDirectoryName(fs.Directory.GetCurrentDirectory());\n```\n\n## SubDirectory extension\n\n```csharp\nvar current = new FileSystem().CurrentDirectory();\n\n//create a \"temp\" subdirectory with extension\ncurrent.SubDirectory(\"temp\").Create();\n\n//create a \"temp\" subdirectory without extension\ncurrent.FileSystem.DirectoryInfo.FromDirectoryName(current.FileSystem.Path.Combine(current.FullName, \"temp\")).Create();\n```\n\n## File extension\n\n```csharp\nvar current = new FileSystem().CurrentDirectory();\n\n//create a \"test.txt\" file with extension\nusing (var stream = current.File(\"test.txt\").Create())\n    stream.Dispose();\n\n//create a \"test.txt\" file without extension\nusing (var stream = current.FileSystem.FileInfo.FromFileName(current.FileSystem.Path.Combine(current.FullName, \"test.txt\")).Create())\n    stream.Dispose();\n```\n\n## Automatic cleanup with Disposable extensions\n\nUse `CreateDisposableDirectory` or `CreateDisposableFile` to create a `IDirectoryInfo` or `IFileInfo` that's automatically\ndeleted when the returned `IDisposable` is disposed.\n\n```csharp\nvar fs = new FileSystem();\n\n//with extension\nusing (fs.CreateDisposableDirectory(out IDirectoryInfo dir))\n{\n    Console.WriteLine($\"This directory will be deleted when control leaves the using block: '{dir.FullName}'\");\n}\n\n//without extension\nvar temp = fs.Path.GetTempPath();\nvar fileName = fs.Path.GetRandomFileName();\nvar path = fs.Path.Combine(temp, fileName);\n\ntry\n{\n    IDirectoryInfo dir = fs.Directory.CreateDirectory(path);\n    Console.WriteLine($\"This directory will be deleted in the finally block: '{dir.FullName}'\");\n}\nfinally\n{\n    fs.Directory.Delete(path, recursive: true);\n}\n```\n\n## IDirectoryInfo.CopyTo extension\n```csharp\nvar fs = new FileSystem();\nvar current = fs.CurrentDirectory();\n\n//source\nvar source =  current.SubDirectory(\"source\");\nsource.Create(); //make sure the source directory exists\n\n//destination\nvar dest = current.SubDirectory(\"destination\");\n\n//copy\nsource.CopyTo(dest, recursive: true);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestableio%2Fsystem.io.abstractions.extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftestableio%2Fsystem.io.abstractions.extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestableio%2Fsystem.io.abstractions.extensions/lists"}