我在使用IrisSkin4.dll美化winform窗口时想将窗口皮肤导入一个文本文件中便于操作,所有窗口皮肤保存在Skins文件夹中,因此我写了如下的小程序,思路及代码代码都比较简单。(窗体应用程序)
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.IO;
namespace GetFileName
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
skinEngine1.SkinFile = "Skins//DiamondRed.ssk";
}
private void button1_Click(object sender, EventArgs e) //对应界面上的RUN按钮
{
if (string.IsNullOrEmpty(Address.Text) || string.IsNullOrEmpty(FileType.Text) || string.IsNullOrEmpty(FileName.Text))
return;
else //使用三个文本框分别储存文件夹的地址,输出文本文件的名字、后缀
{
FileStream fs = new FileStream(FileName.Text+ '.' + FileType.Text, FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs); // 创建写入流
var files = Directory.GetFiles(Address.Text)
foreach (var file in files)
{
sw.WriteLine(Path.GetFileName(file));
}
sw.Close();
MessageBox.Show("Succeed","result");
}
}
}
}
程序运行截图