https://github.com/ex-exe/buffercopy
Copy file and reports read/write progress.
https://github.com/ex-exe/buffercopy
copy csharp file library tool
Last synced: 12 months ago
JSON representation
Copy file and reports read/write progress.
- Host: GitHub
- URL: https://github.com/ex-exe/buffercopy
- Owner: EX-EXE
- License: mit
- Created: 2022-10-01T10:48:11.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-11-19T01:13:51.000Z (over 2 years ago)
- Last Synced: 2024-04-26T11:47:15.767Z (about 2 years ago)
- Topics: copy, csharp, file, library, tool
- Language: C#
- Homepage:
- Size: 136 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BufferCopy / CopyFileUtility
[](https://badge.fury.io/nu/CopyFileUtility)
[](https://github.com/EX-EXE/BufferCopy/actions/workflows/build.yml)
Copy file and reports read/write progress.
| File | Directory |
|---|---|
|  |  |
## Project
| Name | Type| Description |
|---|---|---|
| CopyFileUtility | C# Library [](https://badge.fury.io/nu/CopyFileUtility) | Copy Process |
| BufferCopy | Application | Using CopyFileUtility |
## Quick Start(BufferCopy)
### File
```
BufferCopy.exe File
```
| Param | Description |
|---|---|
| SrcFile | Source file path. |
| DstFile | Destination file path. |
### Directory
```
BufferCopy.exe Dir
```
```
BufferCopy.exe Directory
```
| Param | Description |
|---|---|
| SrcDir | Source directory path. |
| DstDir | Destination directory path. |
## Quick Start(CopyFileUtility)
### File
```csharp
await CopyFileUtility.CopyFileAsync(
string src,
string dst,
CopyFileOptions option,
IProgress? progress = null,
CancellationToken cancellationToken = default);
```
| Param | Description |
|---|---|
| src | Source file path. |
| dst | Destination file path. |
| option | Copy option. |
### Files
```csharp
await CopyFileUtility.CopyFilesAsync(
IEnumerable srcFiles,
IEnumerable dstFiles,
CopyFileOptions options,
bool throwCopyException = false,
IProgress? progress = null,
CancellationToken cancellationToken = default);
```
| Param | Description |
|---|---|
| srcFiles | Source files path. |
| dstFiles | Destination files path. |
| option | Copy option. |
| throwCopyException | Throw when an exception occurs during file copying. |
### Directory
```csharp
await CopyFileUtility.CopyDirectoryAsync(
string src,
string dst,
System.IO.SearchOption searchOption,
CopyFileOptions copyOptions,
bool throwCopyException = false,
IProgress? progress = null,
CancellationToken cancellationToken = default);
```
```csharp
await CopyFileUtility.CopyDirectoryAsync(
string src,
string dst,
Regex?|string? includeSrcPathRegex,
Regex?|string? excludeSrcPathRegex,
Func? changePathFunction,
System.IO.SearchOption searchOption,
CopyFileOptions copyOptions,
bool throwCopyException = false,
IProgress? progress = null,
CancellationToken cancellationToken = default);
```
| Param | Description |
|---|---|
| src | Source directory path. |
| dst | Destination directory path. |
| includeSrcPathRegex | Filtering copy targets using regular expressions.(Target all files if null.) |
| excludeSrcPathRegex | Exclude copy targets using regular expressions.(Do nothing if null.) |
| changePathFunction | Change the destination file path.
in: string srcFile,string dstFile,string relativePath
out: string changeDstFile(Do not copy if empty.)
(Do nothing if null.)
| searchOptions | Search top directory or all subdirectories. |
| copyOptions | Copy option. |
| throwCopyException | Throw when an exception occurs during file copying. |
## Performance
[Ver1.2.0 Copy File(1GiB)](https://github.com/EX-EXE/BufferCopy/actions/runs/3234056253)
### Windows
| Method | Mean | Error | StdDev | Allocated | buffer | pool |
|-------------------- |------------:|------------:|------------:|-----------:|-------- |----- |
| **System.IO.File.Copy** | **1,064.0 ms** | **2,762.8 ms** | **151.44 ms** | **480 B** | **?** | **?** |
| **BufferCopy** | **550.8 ms** | **1,508.3 ms** | **82.68 ms** | **8398720 B** | **1048576** | **8** |
| **BufferCopy** | **707.6 ms** | **2,048.2 ms** | **112.27 ms** | **16788136 B** | **1048576** | **16** |
| **BufferCopy** | **760.5 ms** | **1,987.2 ms** | **108.93 ms** | **31470352 B** | **1048576** | **30** |
### Ubuntu
| Method | Mean | Error | StdDev | Allocated | buffer | pool |
|-------------------- |---------:|----------:|---------:|--------------:|-------- |----- |
| **System.IO.File.Copy** | **5.297 s** | **2.3075 s** | **0.1265 s** | **1.56 KB** | **?** | **?** |
| **BufferCopy** | **1.460 s** | **0.4060 s** | **0.0223 s** | **8204.26 KB** |**1048576** | **8** |
| **BufferCopy** | **1.483 s** | **7.7781 s** | **0.4263 s** | **16394.88 KB** |**1048576** | **16** |
| **BufferCopy** | **1.686 s** | **2.4515 s** | **0.1344 s** | **30732.85 KB** |**1048576** | **30** |