using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace zhang_Test
{
class Program
{
private static void Main(string[] args)
{


InitSchemes dd = new InitSchemes();
string ddds = dd.GetInitSchemes(null);
}

}
/// <summary>
/// 出厂原始数据
/// </summary>
public class InitSchemes
{
public string GetInitSchemes(Assembly resourceAssembly = null, string resourceName = "zhang_Test.test.txt")
{
if (resourceAssembly == null)
{
resourceAssembly = this.GetType().Assembly;
}

string json = resourceAssembly.Resource(resourceName);


return json;
}
}
public static class AssemblyExtensions
{
public static string Resource(this Assembly self, string name, Encoding encoding = null)
{

var stream = self.GetManifestResourceStream(name);
if (stream == null)
{
return null;
}

if (!stream.CanRead)
{
return string.Empty;
}

//结果
var result = string.Empty;
using (var streamReader = encoding != null ? new StreamReader(stream, encoding) : new StreamReader(stream, Encoding.UTF8))
{
result = streamReader.ReadToEnd();
}

return result;
}
}
}

相关文章:

  • 2021-10-11
  • 2022-12-23
  • 2021-04-02
  • 2021-04-06
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-10-12
  • 2022-12-23
  • 2022-01-20
  • 2022-01-16
  • 2021-10-27
  • 2021-09-13
相关资源
相似解决方案