Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用于读取检测文件´的配置文件(xml或json)的库;变化_C#_Asp.net_Config_Readfile_Xml Configuration - Fatal编程技术网

C# 用于读取检测文件´的配置文件(xml或json)的库;变化

C# 用于读取检测文件´的配置文件(xml或json)的库;变化,c#,asp.net,config,readfile,xml-configuration,C#,Asp.net,Config,Readfile,Xml Configuration,我有一个XML配置文件,如下所示: <configuration> <items> <item key="KEY_NAME"> 3 </item> </items> </configuration> 3. 我需要一些库来读取(只读取)文件值,但可以检测到更改(例如,更改值3为5),而无需重新启动应用程序 我用过这个,但这个项目被否决了。我发现,你知道其他图书馆吗 谢谢,为什么不使用官方类

我有一个XML配置文件,如下所示:

<configuration>
<items>
    <item key="KEY_NAME">
        3
    </item>
</items>
</configuration>

3.
我需要一些库来读取(只读取)文件值,但可以检测到更改(例如,更改值3为5),而无需重新启动应用程序

我用过这个,但这个项目被否决了。我发现,你知道其他图书馆吗

谢谢,

为什么不使用官方类来观看文件系统

示例如下:

using (FileSystemWatcher watcher = new 
FileSystemWatcher())
    {
        watcher.Path = args[1];

        // Watch for changes in LastAccess and LastWrite times, and
        // the renaming of files or directories.
        watcher.NotifyFilter = NotifyFilters.LastAccess
                             | NotifyFilters.LastWrite
                             | NotifyFilters.FileName
                             | NotifyFilters.DirectoryName;

        // Only watch text files.
        watcher.Filter = "*.xml";

        // Add event handlers.
        watcher.Changed += OnChanged;

        // Begin watching.
        watcher.EnableRaisingEvents = true;

        // Wait for the user to quit the program.
        Console.WriteLine("Press 'q' to quit the sample.");
        while (Console.Read() != 'q') ;
    }
}

// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e) =>
    // Specify what is done when a file is changed, created, or deleted.
    Console.WriteLine($"File: {e.FullPath} {e.ChangeType}");
}
在on changed事件中,可以重新加载文件和值


这就是Njupiter现在被弃用的原因

谢谢。它在NetFramework 4.5上可用吗?是的!检查