Compare commits
No commits in common. "4da75bfa8a5905842385a6f16c7b886242470bb3" and "f2cdfc86b7293e039433952f7772e380474d0ff0" have entirely different histories.
4da75bfa8a
...
f2cdfc86b7
@ -2,7 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!--package info-->
|
<!--package info-->
|
||||||
<PackageId>DTLib</PackageId>
|
<PackageId>DTLib</PackageId>
|
||||||
<Version>1.6.2</Version>
|
<Version>1.6.1</Version>
|
||||||
<Authors>Timerix</Authors>
|
<Authors>Timerix</Authors>
|
||||||
<Description>Library for all my C# projects</Description>
|
<Description>Library for all my C# projects</Description>
|
||||||
<RepositoryType>GIT</RepositoryType>
|
<RepositoryType>GIT</RepositoryType>
|
||||||
|
|||||||
@ -60,37 +60,16 @@ public static class File
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ReadAllText(IOPath file) => ReadAllBytes(file).BytesToString(StringConverter.UTF8);
|
||||||
public static async Task<byte[]> ReadAllBytesAsync(IOPath file)
|
|
||||||
{
|
|
||||||
using System.IO.FileStream stream = OpenRead(file);
|
|
||||||
int size = GetSize(file).ToInt();
|
|
||||||
byte[] output = new byte[size];
|
|
||||||
if (await stream.ReadAsync(output, 0, size).ConfigureAwait(false) < size)
|
|
||||||
throw new Exception("can't read all bytes");
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string ReadAllText(IOPath file) =>
|
|
||||||
ReadAllBytes(file).BytesToString(StringConverter.UTF8);
|
|
||||||
public static async Task<string> ReadAllTextAsync(IOPath file) =>
|
|
||||||
(await ReadAllBytesAsync(file)).BytesToString(StringConverter.UTF8);
|
|
||||||
|
|
||||||
public static void WriteAllBytes(IOPath file, byte[] content)
|
public static void WriteAllBytes(IOPath file, byte[] content)
|
||||||
{
|
{
|
||||||
using System.IO.FileStream stream = OpenWrite(file);
|
using System.IO.FileStream stream = OpenWrite(file);
|
||||||
stream.Write(content, 0, content.Length);
|
stream.Write(content, 0, content.Length);
|
||||||
}
|
}
|
||||||
public static async Task WriteAllBytesAsync(IOPath file, byte[] content)
|
|
||||||
{
|
|
||||||
using System.IO.FileStream stream = OpenWrite(file);
|
|
||||||
await stream.WriteAsync(content, 0, content.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task WriteAllText(IOPath file, string content) =>
|
public static void WriteAllText(IOPath file, string content) =>
|
||||||
await WriteAllBytesAsync(file, content.ToBytes(StringConverter.UTF8));
|
WriteAllBytes(file, content.ToBytes(StringConverter.UTF8));
|
||||||
public static async Task WriteAllTextAsync(IOPath file, string content) =>
|
|
||||||
await WriteAllBytesAsync(file, content.ToBytes(StringConverter.UTF8));
|
|
||||||
|
|
||||||
public static void AppendAllBytes(IOPath file, byte[] content)
|
public static void AppendAllBytes(IOPath file, byte[] content)
|
||||||
{
|
{
|
||||||
@ -98,18 +77,9 @@ public static class File
|
|||||||
stream.Write(content, 0, content.Length);
|
stream.Write(content, 0, content.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task AppendAllBytesAsync(IOPath file, byte[] content)
|
|
||||||
{
|
|
||||||
using System.IO.FileStream stream = OpenAppend(file);
|
|
||||||
await stream.WriteAsync(content, 0, content.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AppendAllText(IOPath file, string content) =>
|
public static void AppendAllText(IOPath file, string content) =>
|
||||||
AppendAllBytes(file, content.ToBytes(StringConverter.UTF8));
|
AppendAllBytes(file, content.ToBytes(StringConverter.UTF8));
|
||||||
|
|
||||||
public static async Task AppendAllTextAsync(IOPath file, string content) =>
|
|
||||||
await AppendAllBytesAsync(file, content.ToBytes(StringConverter.UTF8));
|
|
||||||
|
|
||||||
public static System.IO.FileStream OpenRead(IOPath file)
|
public static System.IO.FileStream OpenRead(IOPath file)
|
||||||
{
|
{
|
||||||
if (!Exists(file))
|
if (!Exists(file))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user