如何用C#实现winform功能 小弟用C#写了一个winform 程序界面(图1),主要实现从电脑上的网络盘每天定时获取备份文件的大小,然后自动写入指定位置的excel文件(图2)中自动保存。现在能够实现手动选择文件获取到大小,但是不知道如何实现写到指定位置的Excel中,请各路前辈指点一下代码。最好能够解决实现程序一直运行,每天早上9点自动获取备份大写,然后自动写入网络盘上的excel中,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Runtime.InteropServices;using System.IO;namespace 读取备份信息{ public partial class Frm_Main : Form { public Frm_Main() { InitializeComponent(); } OpenFileDialog open = new OpenFileDialog(); private void button1_Click(object sender, EventArgs e) { if (open.ShowDialog() == DialogResult.OK) { textBox1.Text = open.FileName; } FileInfo MyFileInfo = new FileInfo(open.FileName); float MyFileSize = (float)MyFileInfo.Length / (1024 * 1024); textBox5.Text = MyFileSize.ToString() + "MB"; return; } private void timer1_Tick(object sender, EventArgs e) { DateTime current = DateTime.Now; textBox8.Text = current.Year.ToString()+ "/" + current.Month.ToString() + "/" + current.Day.ToString(); } private void button5_Click(object sender, EventArgs e) { if (open.ShowDialog() == DialogResult.OK) { textBox3.Text = open.FileName; } FileInfo MyFileInfo = new FileInfo(open.FileName); float MyFileSize = (float)MyFileInfo.Length / (1024 * 1024); textBox6.Text = MyFileSize.ToString() + "MB"; return; } private void button6_Click(object sender, EventArgs e) { if (open.ShowDialog() == DialogResult.OK) { textBox4.Text = open.FileName; } FileInfo MyFileInfo = new FileInfo(open.FileName); float MyFileSize = (float)MyFileInfo.Length / (1024 * 1024); textBox7.Text = MyFileSize.ToString() + "MB"; return; } private void button2_Click(object sender, EventArgs e) { if (open.ShowDialog() == DialogResult.OK) { textBox2.Text = open.FileName; } } private void button3_Click(object sender, EventArgs e) { Workbook workbook = new Workbook(); } }}目前的代码写到这里了,就是下面的写不下去了,求指导(如何将备份大小信息写到指定位置的excel中) 搜索 C# NPOI 自动定时备份,写入EXCEL需要使用定时服务1.写一个C#的服务,定时执行备份和写EXCEL任务.2.C#操作EXCEL,工具类很多,NPOI,或者逗号分隔的文本也行 从TextBox1自动跳到TextBox2。谁会? 求救!webbrowser vs2005 移植到 VS2003 C#中 事务处理 控制 两张以上的表~是不是100% 不会出错???? 给分求助,为什么报表显示的数据有很多行,而执行同样的sql只有1行数据? 问个很弱的问题--在winForm下如何获得程序运行的当前路径? 如何解决:未能找到任何适合于指定的区域性或非特定区域性的资源 Session问题。 C#如何把textbox里的中文转换成unicode 请问 关于 Shell 钩子的 1个题 急!!! SQL如何快速批量查询数据 浙大中控Rbus协议解析
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;namespace 读取备份信息
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
} OpenFileDialog open = new OpenFileDialog(); private void button1_Click(object sender, EventArgs e)
{
if (open.ShowDialog() == DialogResult.OK)
{
textBox1.Text = open.FileName;
}
FileInfo MyFileInfo = new FileInfo(open.FileName);
float MyFileSize = (float)MyFileInfo.Length / (1024 * 1024);
textBox5.Text = MyFileSize.ToString() + "MB";
return;
} private void timer1_Tick(object sender, EventArgs e)
{
DateTime current = DateTime.Now;
textBox8.Text = current.Year.ToString()+ "/" + current.Month.ToString() + "/" + current.Day.ToString();
} private void button5_Click(object sender, EventArgs e)
{
if (open.ShowDialog() == DialogResult.OK)
{
textBox3.Text = open.FileName;
}
FileInfo MyFileInfo = new FileInfo(open.FileName);
float MyFileSize = (float)MyFileInfo.Length / (1024 * 1024);
textBox6.Text = MyFileSize.ToString() + "MB";
return; } private void button6_Click(object sender, EventArgs e)
{
if (open.ShowDialog() == DialogResult.OK)
{
textBox4.Text = open.FileName;
}
FileInfo MyFileInfo = new FileInfo(open.FileName);
float MyFileSize = (float)MyFileInfo.Length / (1024 * 1024);
textBox7.Text = MyFileSize.ToString() + "MB";
return;
} private void button2_Click(object sender, EventArgs e)
{
if (open.ShowDialog() == DialogResult.OK)
{
textBox2.Text = open.FileName;
}
} private void button3_Click(object sender, EventArgs e)
{
Workbook workbook = new Workbook();
}
}
}
目前的代码写到这里了,就是下面的写不下去了,求指导(如何将备份大小信息写到指定位置的excel中)
1.写一个C#的服务,定时执行备份和写EXCEL任务.
2.C#操作EXCEL,工具类很多,NPOI,或者逗号分隔的文本也行