C#怎么在指定路径下建立一个文件夹?
C#怎么在指定路径下建立一个文件夹?
然后在该文件夹下创建一个内容由自己编辑的htm文件?
给一个小小的实例把。
谢谢。
问题点数:50、回复次数:4Top
1 楼Mittermeyer(疾风之狼)回复于 2003-11-03 08:48:29 得分 20
简单的写是这个样子的
System.IO.StreamWriter stmPage = null;
Directory.CreateDirectory("yourfolderpath");
m_sPage = "youfilename";
if (!File.Exists(m_sPage))
{
try
{
stmPage = new StreamWriter(m_sPage,true);
if (stmPage != null)
{
stmPage.WriteLine("yourfilecontents");
stmPage.Close();
stmPage = null;
}
}
catch(System.Exception e)
{
}
}
Top
2 楼wwonion(洋葱)回复于 2003-11-03 08:51:34 得分 15
using System.IO;
string path=@"c:\test"
if(Directory.Exists(path)==false) {//判断目录是否存在
//创建目录
Directory.CreateDirectory(path);
}Top
3 楼asam2183(三山)回复于 2003-11-03 08:57:40 得分 10
string sPath=Server.MapPath(".")+"XX";
if(!Directory.Exists(sPath))
Directory.CreateDirectory(sPath);Top
4 楼chinanewway(新路了无痕)回复于 2003-11-03 09:00:43 得分 5
upTop




