[英]Write in Log file c#
我有一個代碼,我從XML文件中讀取必須保存結果的路徑,並且如果程序中有錯誤並且停止,請記下錯誤。
我的程序具有以下結構:
namespace RiskFactorListUpdater
{
public static class Program
{
public static void Main(string[] args)
{
try
{
//get the data
filename=.....;
// blah blah blah
// more code
}catch(Exception e)
{
//write in log file
}
當我嘗試讀取文件名路徑時,就會出現問題。 我在“捕獲”部分中看不到它。 我是C#的新手。 有一個簡單的方法嗎?
提前致謝
在try
塊之前,聲明要在catch
塊中使用的任何內容。
public static class Program
{
public static void Main(string[] args)
{
string filename;
try
{
//get the data
filename=.....;
// blah blah blah
// more code
}catch(Exception e)
{
//write in log file
}
you can use below method in proper formating way.
public static class Program
{
public static string filename {get;set}
public static void Main(string[] args)
{
filename="";
try
{
filename=.....;
}
catch(Exception e)
{
//write in log file
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.