File & Directory
来源:互联网 发布:北京淘宝推广培训 编辑:程序博客网 时间:2024/06/08 04:50
写文件:
StreamWriter rw = System.IO.File.CreateText(System.Web.HttpContext.Current.Server.MapPath("~/") + "//CreateText.txt"); rw.WriteLine(new Exception().ToString()); rw.Flush(); rw.Close();
获取目录下匹配的文件集(不含子文件夹内匹配的文件):
System.IO.Directory.GetFiles(string path);System.IO.Directory.GetFiles(string path, string searchPattern);System.IO.Directory.GetFiles(string path, string searchPattern, SearchOption searchOption);
递归创建目录:
private void createdir(string filefullpath) { if (!File.Exists(filefullpath)) { string dirpath = filefullpath.Substring(0, filefullpath.LastIndexOf('\\')); string[] pathes = dirpath.Split('\\'); if (pathes.Length > 1) { string path = pathes[0]; for (int i = 1; i < pathes.Length; i++) { path += "\\" + pathes[i]; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } } } }
调用:
createdir(Server.MapPath("/Data/EF/Test/"));
参考:http://wenku.baidu.com/link?url=AK7kl7IjlkIz-EnodH7dsxdsLWs5ZtZ9Dd3uuJozE1wim52YtWMQFFjD5qhujmkmm0uJ_2_U6qvI6gCrdaU6U4oM6H5n8mWhk9jhq0W9U5S
0 0
- File & Directory
- File and directory.
- File , Folder 与 Directory
- File and Directory Enumeration
- File and directory.
- linux file and directory
- no file or directory.....
- linux file System directory
- Terminal File & Directory Commands
- debug-file-directory
- file and directory
- File.Exists与Directory.Exists
- No such file or directory
- File类与Directory类
- C++ Delete Directory and File
- Powershell with file and directory
- No such file or directory
- File类和Directory类
- 无线AP信道(Channel)详解
- CCRect
- 软件测试分类
- 女人、 爱自己从护肤开始
- 一行命令搞定VS2012无法安装cocos2d-x-2.1.4及创建跨平台项目(二)
- File & Directory
- Naive Bayes Classification
- mysql忘记root密码怎么办
- Ajax乱码解决方案
- Perl学习书籍汇总
- Storm相关
- cocos2d-x2.2.2(2.1.4及以上版本) VS2012 创建跨平台项目秒杀方法
- Pow(x, n)
- ui思想:抽象工厂,工厂方法