创建CSV文件并通过c#每5分钟在其中添加数据。 [英] Creating CSV file and adding data in it every 5 min by c#.

查看:300
本文介绍了创建CSV文件并通过c#每5分钟在其中添加数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生。


我正在开发SCADA项目。我们有内置脚本选项,它使用C#语言。根据要求,我们需要对应用程序进行编码,它将每小时创建一个csv文件,但其中修补的数据(CSV文件)应该是
5分钟的间隔。



请建议我该怎么办。


如果可能,请给我一些示例程序,因为我不是软件工程师。

解决方案

< blockquote>

创建一个包含文件数据的列表。


创建一个每五分钟计时一次的计时器。


创建一个计数器(初始值为零的整数。


在计时器的tick事件中,将最新数据添加到列表中,然后递增计数器。如果计数器为12,则写入文件并将计数器重置为零。


https://msdn.microsoft.com/en-us/library/system.threading.timer%28v=vs.110%29.aspx


Dear sir.

I am working on a SCADA project.We have inbuilt scripting option which uses C# language.As per requirement we need to code the application as such that It will create a csv file every hour but the data patched in it(CSV file) should be at the interval of 5 min.

Please suggest how can I do it.

If possible please give me some sample program as I am not a software engineer.

解决方案

Create a list that holds data for the file.

Create a timer that ticks every five minutes.

Create a counter (integer) with an initial value of zero.

In the timer's tick event, add the latest data to the list, then increment the counter. If the counter is 12, write the file and reset the counter to zero.

https://msdn.microsoft.com/en-us/library/system.threading.timer%28v=vs.110%29.aspx


这篇关于创建CSV文件并通过c#每5分钟在其中添加数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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