using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace URLsearching
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string dir = "C:\\A\\" + textBox1.Text;
if (Directory.Exists(dir))
{
string[] files = Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories);
}
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
}
}
我就写成这样子,我也不知道现在写的对不对,就算对了,我也有个问题就是想问怎么把路径输出到TextBox2中?
新手程序员,对C#完全不熟悉,但是因为马上要交给客户,求各路大神给完整代码
思路如下:
winform中两个TextBox,一个button,用户对TextBox1输入一段字符,点击button,TextBox2输出绝对路径(已可以确定输入的文件名是精确的,所以精确搜索就可以,不用模糊查找,另外就是要搜索到文件夹下的所有子文件夹)
您好,我是希望通过输入字符串进行对某一文件的搜索并输出路径到TextBox