資源簡介
實現10路串口數據的采集,顯示,解析保存,并能夠實時圖表顯示

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.IO;
using?System.Linq;
using?System.Text;
namespace?WindowsFormsApplication2
{
????public?interface?IUpdateTxt
????{
????????void?Save(string?data);
????????bool?Start(string?path?string?flag?string?header);
????????void?Stop();
????}
????class?UpdateTxt?:?IUpdateTxt
????{
????????private?string?path;
????????private?string?text;
????????public?void?SetPath(string?path?string?Index)
????????{
????????????DateTime?dt?=?DateTime.Now;
????????????string?time?=?string.Format(“{0:yyyyMMddHHmmssffff}“?dt);
????????????this.path?=?path?+?“\\“?+?Index?+?“_“?+?time?+?“.txt“;
????????????FileStream?fs1?=?new?FileStream(this.path?FileMode.Create);//創建寫入文件
????????????fs1.Close();
????????}
????????public?void?Save(string?data)
????????{
????????????_Save(System.DateTime.Now.ToString()?+?“;“?+?data);
????????}
????????private?void?_Save(string?data)
????????{
????????????if?(!save)
????????????{
????????????????return;
????????????}
????????????if?(path?==?null)
????????????{
????????????????return;
????????????}
????????????StreamWriter?sw?=?new?StreamWriter(path?true);
????????????sw.WriteLine(data);
????????????sw.Close();
????????}
????????private?bool?save?=?false;
????????public?bool?Start(string?path?string?flag?string?header)
????????{
????????????try
????????????{
????????????????DateTime?dt?=?DateTime.Now;
????????????????string?time?=?string.Format(“{0:yyyyMMddHHmmssffff}“?dt);
????????????????this.path?=?path?+?“\\“?+?flag?+?“_“?+?time?+?“.txt“;
????????????????FileStream?fs1?=?new?FileStream(this.path?FileMode.Create);//創建寫入文件
????????????????fs1.Close();
????????????????save?=?true;
????????????????_Save(header);
????????????????return?save;
????????????}
????????????catch?(Exception)
????????????{
????????????????save?=?false;
????????????????return?save;
????????????}
????????}
????????public?void?Stop()
????????{
????????????save?=?false;
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????49664??2018-05-29?17:29??WindowsFormsApplication4\.vs\WindowsFormsApplication2\v14\.suo
?????文件??????23552??2018-05-29?15:01??WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe
?????文件??????38400??2018-05-29?15:01??WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb
?????文件??????22688??2018-05-29?15:37??WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe
?????文件????????490??2015-12-02?08:23??WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.manifest
?????文件???????2085??2018-05-22?16:57??WindowsFormsApplication4\WindowsFormsApplication2\daterecive.cs
?????文件??????20842??2018-05-29?15:00??WindowsFormsApplication4\WindowsFormsApplication2\Form1.cs
?????文件??????24107??2018-05-23?12:15??WindowsFormsApplication4\WindowsFormsApplication2\Form1.Designer.cs
?????文件???????6189??2018-05-23?12:15??WindowsFormsApplication4\WindowsFormsApplication2\Form1.resx
?????文件???????1452??2018-05-23?12:18??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6944??2018-05-25?17:36??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????2814??2018-05-29?15:38??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.FileListAbsolute.txt
?????文件???????1012??2018-05-25?14:55??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.GenerateResource.Cache
?????文件???????2210??2018-05-29?15:01??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csprojResolveAssemblyReference.cache
?????文件??????23552??2018-05-29?15:01??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.exe
?????文件????????180??2018-05-25?14:55??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Form1.resources
?????文件??????38400??2018-05-29?15:01??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.pdb
?????文件????????180??2018-05-25?14:55??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Properties.Resources.resources
?????文件????????505??2018-05-21?17:52??WindowsFormsApplication4\WindowsFormsApplication2\Program.cs
?????文件???????1356??2018-05-21?17:52??WindowsFormsApplication4\WindowsFormsApplication2\Properties\AssemblyInfo.cs
?????文件???????2861??2018-05-21?17:52??WindowsFormsApplication4\WindowsFormsApplication2\Properties\Resources.Designer.cs
?????文件???????5612??2018-05-21?17:52??WindowsFormsApplication4\WindowsFormsApplication2\Properties\Resources.resx
?????文件???????1111??2018-05-21?17:52??WindowsFormsApplication4\WindowsFormsApplication2\Properties\Settings.Designer.cs
?????文件????????249??2018-05-21?17:52??WindowsFormsApplication4\WindowsFormsApplication2\Properties\Settings.settings
?????文件???????3803??2018-05-22?16:57??WindowsFormsApplication4\WindowsFormsApplication2\WindowsFormsApplication2.csproj
?????文件???????1039??2018-05-21?17:52??WindowsFormsApplication4\WindowsFormsApplication2.sln
?????目錄??????????0??2018-05-21?17:52??WindowsFormsApplication4\WindowsFormsApplication2\obj\Debug\TempPE
?????目錄??????????0??2018-05-25?17:34??WindowsFormsApplication4\.vs\WindowsFormsApplication2\v14
?????目錄??????????0??2018-05-25?17:34??WindowsFormsApplication4\WindowsFormsApplication2\bin\Debug
?????目錄??????????0??2018-05-22?16:45??WindowsFormsApplication4\WindowsFormsApplication2\bin\Release
............此處省略11個文件信息
- 上一篇:C#開發Web留言板功能
- 下一篇:C# 計算器 仿windows計算器
評論
共有 條評論