diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs
index 0f4514a066..21ca7c2086 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/IO/FileHelper.cs
@@ -1,4 +1,7 @@
-using System.IO;
+using System;
+using System.IO;
+using System.Text;
+using System.Threading.Tasks;
using JetBrains.Annotations;
namespace Volo.Abp.IO
@@ -41,5 +44,35 @@ namespace Volo.Abp.IO
return fileNameWithExtension.Substring(lastDotIndex + 1);
}
+
+ ///
+ /// Opens a text file, reads all lines of the file, and then closes the file.
+ ///
+ /// The file to open for reading.
+ /// A string containing all lines of the file.
+ public static async Task ReadAllTextAsync(string path)
+ {
+ using (var reader = File.OpenText(path))
+ {
+ return await reader.ReadToEndAsync();
+ }
+ }
+
+ ///
+ /// Opens a text file, reads all lines of the file, and then closes the file.
+ ///
+ /// The file to open for reading.
+ /// A string containing all lines of the file.
+ public static async Task ReadAllBytesAsync(string path)
+ {
+ using (var stream = File.Open(path, FileMode.Open))
+ {
+ var result = new byte[stream.Length];
+ await stream.ReadAsync(result, 0, (int)stream.Length);
+ return result;
+ }
+ }
+
+ //TODO: ReadAllLinesAsync
}
}
\ No newline at end of file
diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/FileSystem/Documents/FileSystemDocumentStore.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/FileSystem/Documents/FileSystemDocumentStore.cs
index a0a341fa04..dccc99fc75 100644
--- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/FileSystem/Documents/FileSystemDocumentStore.cs
+++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/FileSystem/Documents/FileSystemDocumentStore.cs
@@ -2,6 +2,7 @@
using System.IO;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
+using Volo.Abp.IO;
using Volo.Docs.Documents;
using Volo.Docs.FileSystem.Projects;
using Volo.Docs.Projects;
@@ -15,7 +16,7 @@ namespace Volo.Docs.FileSystem.Documents
public async Task GetDocument(Project project, string documentName, string version)
{
var path = Path.Combine(project.GetFileSystemPath(), documentName);
- var content = File.ReadAllText(path); //TODO: async!
+ var content = await FileHelper.ReadAllTextAsync(path);
var localDirectory = "";
if (documentName.Contains("/"))
@@ -43,7 +44,7 @@ namespace Volo.Docs.FileSystem.Documents
public async Task GetResource(Project project, string resourceName, string version)
{
var path = Path.Combine(project.GetFileSystemPath(), resourceName);
- return new DocumentResource(File.ReadAllBytes(path));
+ return new DocumentResource(await FileHelper.ReadAllBytesAsync(path));
}
}
}