当前位置:网站首页>.net core 将错误抛出写入.txt文件
.net core 将错误抛出写入.txt文件
2022-04-21 06:38:00 【Gentleness901】
#region 写入文件 如果存在该文件就递加,如果不存在就新建
/// <summary>
/// 写入文件
/// </summary>
/// <param name="Path">文件路径</param>
/// <param name="content">文件内容</param>
//调用示例
//string webRootPath = _hostingEnvironment.WebRootPath; //获取相对路径
//string strUploadPath = webRootPath + "/Document/";
//string fileLogName = "错误日志" + DateTime.Now.ToLongDateString() + "Log.txt";
//WriteFile(strUploadPath + fileLogName, "测试内容");
public static void WriteFile(string path, string content)
{
if (!System.IO.File.Exists(path))
{
System.IO.FileStream f = System.IO.File.Create(path);
f.Close();
}
System.IO.StreamWriter f2 = new System.IO.StreamWriter(path, true, System.Text.Encoding.GetEncoding("gb2312"));
f2.WriteLine(content);
f2.Close();
f2.Dispose();
}
#endregion
版权声明
本文为[Gentleness901]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Fierceness901/article/details/124266537
边栏推荐
- 2020-12-21至2022-1-2:解析观察者模式
- Outh2的基本概念
- 浏览器跨域问题小结
- 虚拟机安装kali 时的默认密码(官网vmx 文件源)
- 根据二维数组某个字段的值查找数组
- Dip image smoothing
- Relationship between application software threads and CPU cores
- IPV4-IGP
- GeoServer 2.20.1 solving cross domain problems CORS
- 论文阅读:Measuring the Impact of a Successful DDoS Attack on the Customer Behaviour of Managed DNS Servi
猜你喜欢
随机推荐
Ctf-rsa decryption script
Implementation of crud of user management system with JDBC
delphi的json类:SuperObject,以及简单用法jsonHelper
Plsql14 software package download, localization and registration
TCP三次握手和四次挥手简介(2022.4.18-4.24)
虚拟机安装kali 时的默认密码(官网vmx 文件源)
Ruijie eg easy gateway remote command execution vulnerability-1
You cannot set a form field before rendering a field associated with the value
SHA256 Hashes
论文阅读:Analyzing Third Party Service Dependencies in Modern Web Services
Common weak passwords in network security devices
leetcode 59.螺旋矩阵Ⅱ
论文阅读:The Chain of Implicit Trust: An Analysis of the Web Third-party Resources Loading
中介者模式(3.28-4.3)
NP, OSPF route aggregation
mysql where条件后执行规则
MYSQL中批量替换某个字段的部分数据
2021-10-17
Slice upload solves the problem of single file upload
状态模式(4.4-4.10)









