C#中创建文件夹代码
学的东西可是够乱的,最近又转.NET平台,还要做嵌入式开发,这家伙,很陌生啊。
我准备用openfiledialog来打开相机拍下的照片程序,竟然发现无法浏览除了My Documents之外的文件夹,郁闷,用C#创建的文件夹也看不到。
先贴出创建文件夹的代码,问题解决之后再贴openfiledialog:
using System.IO;
private void button2_Click(object sender, EventArgs e)
{
if (Directory.Exists("\\picture"))
{
MessageBox.Show("directory exists");
}
else {
Directory.CreateDirectory("\\picture");
}
}
private void button2_Click(object sender, EventArgs e)
{
if (Directory.Exists("\\picture"))
{
MessageBox.Show("directory exists");
}
else {
Directory.CreateDirectory("\\picture");
}
}
太简单了,不解释了。
版权信息:本文来自老杨个人网站,作者老杨,原文地址,转载请注明出处。
如果喜欢本站,敬请订阅:老杨个人网站。谢谢惠顾!
标签:





看到c#都脸红,我还是学编程的呢,现在就知道个if else
回复Ta
自知不是学编程的那块儿料,打小就是个优秀的文科生
回复Ta