【发布时间】:2009-09-17 17:18:41
【问题描述】:
我在某个文件夹中有一个 xml 文件 sample.xml:
<?xml version="1.0"?>
<!-- Please Enter your frequency value between 10sec to 80sec -->
<Time>
<Value>80</Value>
</Time>
如果任何人输入超出限制,例如 8 或 700,则此 xml 文件将提供给用户显示 如果它是字符串或字母数字,它将向日志文件发送错误消息。
我需要在 try ,catch 块中使用 c# 编码来在日志文件中显示这些内容
这是这个地方意味着他们之前正在执行的功能意味着这里的值是固定的,那时没有xml文件,我们现在需要使用哪个(xml文件)。
public sampleInterface()
{
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();
//
// NetIqInterface
// ## Heading ##
this.CanHandlePowerEvent = false;
this.CanPauseAndContinue = true;
this.CanShutdown = false;
//
// Initialize static variables
//
etl = new EtlDebug( ProjectInstaller.SERVICE_NAME, "netiq", "NIQTRACES" );
if (outstandingTimers == null) outstandingTimers = new ArrayOfTimers();
//
// Initialize polling timer - set to 80 seconds for now.
//
LeafDebug.DebugTraceNormal( "InitializeComponent", "Set polling timer: 60000ms" );
timer = new System.Timers.Timer( 60000 );
timer.Elapsed += new ElapsedEventHandler( OnTimer );
// The method in the Leaf.Resources instantiates the resource
// manager appropriately to access the resource file.
resources = Managers.LeafStrings;
}
【问题讨论】:
-
我上面给出的代码是旧代码。问题是这里所有的东西都硬编码了频率,但是这里我们需要开发一个用户驱动的代码,,,意味着我们需要给一个xml文件用户的值设置在一个限制之间,这就是我们需要的