123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Hosting;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- namespace TEAMModelOS.Helper.Common.FileHelper
- {
- public static class FileTool
- {
-
- public static string getJson(string contentRootPath, string name)
- {
- //string webRootPath = _hostingEnvironment.WebRootPath;
-
- try
- {
- String path = contentRootPath + "/JsonFiled/" + name + ".json";
- //获取正在占用的文件
- FileStream fs = new FileStream(path, System.IO.FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
- StreamReader sr = new StreamReader(fs, System.Text.Encoding.ASCII);
- String line;
- StringBuilder builder = new StringBuilder();
- while ((line = sr.ReadLine()) != null)
- {
- builder.Append(line.ToString());
- }
- sr.Close();
- string log = builder.ToString();
- return log;
- }
- catch (Exception e)
- {
- var s = e.Message;
- return s;
- }
- }
- }
- }
|