using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace warscode
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Interval = 5000;
timer1.Enabled = true;
Console.Write(Environment.UserName);
Console.Write(Environment.MachineName);
//Process.Start("net", "use \\\\192.168.0.104 1234 /user:wfx@MP");
Process.Start("net", "use \\\\10.10.2.111 Eino /user:JOT");
}
DateTime logtime = DateTime.Today;
string datecomponent;
private void timer1_Tick(object sender, EventArgs e)
{
switch (datecomponent)
{
case "":;break;
}
string input = DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss:ffff");
input += "," + logtime.ToLongTimeString()+"\r\n";
//disk D share ipg folder
var _dir = Path.GetDirectoryName(@"\\10.10.2.111\c\jot\Idefix\log\Mea1\");
datecomponent = string.Format("{0:d2}{1:d2}{2:d2}", logtime.Year - 2000, logtime.Month, logtime.Day);
try
{
if (!string.IsNullOrEmpty(_dir))
{
if (!Directory.Exists(_dir))
{
Directory.CreateDirectory(_dir);
}
}
_dir = Path.Combine(_dir, String.Format("{0}_{1}_{2}.log", datecomponent, "alarm", "test"));
string sourceFilePath = @"c:/jot/idefix/log." + datecomponent + ".log";
File.AppendAllText(sourceFilePath, input);
File.Copy(sourceFilePath, _dir, true);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
copy file to local lan PC
最新推荐文章于 2022-02-10 18:40:17 发布