perfmon柜台 [英] perfmon counters

查看:101
本文介绍了perfmon柜台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


 我需要删除执行计数器 文件超过5天。 

有没有办法做到这一点.. 


可以由任务调度程序完成。


请帮助.. 



谢谢   &安培;问候


K.Muthus 




k.muthus

解决方案

嗨kmuthus,


>>  可以由任务计划程序完成。


您想使用任务计划程序实现它,还是通过编码实现?如果是后者,您可以参考以下内容。


到达到此要求,您可以尝试如下所示的代码。在这里,我假设您要删除的文件存储在同一文件夹"D:\ PCFiles"中。

 public partial class Form1:Form 
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender,EventArgs e)
{
//添加注册表
JobManager.Initialize(new MyRegistry());
}
}

公共类MyRegistry:注册表
{
public MyRegistry()
{
//安排行动立即运行并按日间隔运行
Schedule(()=>
{
//获取当前时间
DateTime dtNow = DateTime.Now;
/ / get files
DirectoryInfo TheFolder = new DirectoryInfo(@" D:\ PCFiles");
foreach(TheFolder.GetFiles()中的FileInfo NextFile)
{
TimeSpan ts = dtNow.Subtract(NextFile.LastWriteTime);
//判断时间是否超过五天
if(ts.TotalDays> 5)
{
NextFile.Delete ();
}
}
})。ToRunEvery(1).Days()。At(14,36); //设置时间
}
}

在使用之前,您需要添加"FluentScheduler"。来自"NuGet"。具体操作如下:


右键单击Reference并选择"Manage NuGet Packages ...",



然后输入"FluentScheduler"在搜索栏中安装它:



问候,


Kyle


Hi All ,

 I need to delete the perform counter  files more than 5 days old. 
Is there a way to do this .. 

Can it done by the task scheduler .

Please help .. 

Thanks   & regards

K.Muthus 


k.muthus

解决方案

Hi kmuthus,

>> Can it done by the task scheduler .

Do you want to implement it with Task Scheduler, or implement via coding? If it is the latter, you can refer to the following.

To achieve this requirement, you can try the code shown as follows. Here I assume that the files you want to delete are stored in the same folder "D:\PCFiles".

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // add registry
            JobManager.Initialize(new MyRegistry());
        }
    }

    public class MyRegistry : Registry
    {
        public MyRegistry()
        {
            // Schedule an action to run immediately and on an daily interval
            Schedule(() =>
            {
                // get the current time
                DateTime dtNow = DateTime.Now;
                // get files
                DirectoryInfo TheFolder = new DirectoryInfo(@"D:\PCFiles");
                foreach (FileInfo NextFile in TheFolder.GetFiles())
                {
                    TimeSpan ts = dtNow.Subtract(NextFile.LastWriteTime);
                    // judge if the time is more than five days
                    if (ts.TotalDays > 5)
                    {
                        NextFile.Delete();
                    }
                }
            }).ToRunEvery(1).Days().At(14, 36); // set time
        }
    }

Before using it, you need to add "FluentScheduler" from "NuGet". The specific operation is as follows:

Right click the Reference and select "Manage NuGet Packages...",

then type "FluentScheduler" in the search bar and install it:

Regards,

Kyle


这篇关于perfmon柜台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆