copy file to local lan PC

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());
            }            
        }
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值