C#文件与文件夹操作
(转自:http://www.csharpwin.com/csharpspace/6649r3960.shtml)
C#文件操作:C#追加文件

StreamWriter sw = File.AppendText(

Server.MapPath(".") + "\\myText.txt");

sw.WriteLine("追逐理想");

sw.WriteLine("kzlll");

sw.WriteLine(".NET笔记");

sw.Flush(); sw.Close();
C#文件操作:C#拷贝文件

string OrignFile, NewFile;

OrignFile = Server.MapPath(".") + "\\myText.txt";

NewFile = Server.MapPath(".") + "\\myTextCopy.txt";

File.Copy(OrignFile, NewFile, true);
C#文件操作:C#删除文件
string delFile = Server.MapPath(".") + "\\myTextCopy.txt";
File.Delete(delFile); C#文件操作:C#移动文件

string OrignFile, NewFile;

OrignFile = Server.MapPath(".") + "\\myText.txt";

NewFile = Server.MapPath(".") + "\\myTextCopy.txt";

File.Move(OrignFile, NewFile);
C#文件操作:C#创建目录
// 创建目录c:\sixAge
DirectoryInfo d = Directory.CreateDirectory("c:\\sixAge");
// d1指向c:\sixAge\sixAge1
DirectoryInfo d1= d.CreateSubdirectory("sixAge1");
// d2指向c:\sixAge\sixAge1\sixAge1_1
DirectoryInfo d2= d1.CreateSubdirectory("sixAge1_1");
// 将当前目录设为c:\sixAge
Directory.SetCurrentDirectory("c:\\sixAge");
// 创建目录c:\sixAge\sixAge2
Directory.CreateDirectory("sixAge2");
// 创建目录c:\sixAge\sixAge2\sixAge2_1
Directory.CreateDirectory("sixAge2\\sixAge2_1");
C#文件与文件夹操作的更多相关文章
- [No000083]文件与文件夹操作
#region Folder option 文件夹操作 /// <summary> /// 指定目录是否存在 /// </summary> /// <param name ...
- PHP 文件夹操作「复制、删除、查看大小」递归实现
PHP虽然提供了 filesize.copy.unlink 等文件操作的函数,但是没有提供 dirsize.copydir.rmdirs 等文件夹操作的函数(rmdir也只能删除空目录).所以只能手动 ...
- C# 文件和文件夹操作
一.文件操作 1.File类的常用静态方法: void AppendAllText(string path, string contents),将文本contents附加到文件path中 bool E ...
- Windows Store App 用户库文件夹操作
上面介绍了与用户库文件有关的操作,包括创建.读写等,下面将介绍与用户库文件夹相关的操作. 与文件操作一样,想要对用户库文件夹进行操作,需要首先获取用户库的相应位置,获取的方法上面已经介绍过了,这里不再 ...
- Winform 基础知识 之文件夹操作
using System.IO; /// <summary> /// 删除文件夹下所有文件 /// </summary> /// <param name="di ...
- .Net文件*夹*操作
一.文件夹操作 Directory类,DirectoryInfo类.使用using System.IO命名空间 (一)创建文件夹 方法一: private string path = @"F ...
- Python操作文件、文件夹、字符串
Python 字符串操作 去空格及特殊符号 s.strip().lstrip().rstrip(',') 复制字符串 #strcpy(sStr1,sStr2) sStr1 = 'strcpy' sSt ...
- 【CITE】C#目录、文件、文件夹操作
1. 在一个目录下创建一个文件夹 if (!System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path); ...
- PYTHON对文件及文件夹的一些操作
python中对文件.文件夹的操作需要涉及到os模块和shutil模块. 创建文件:1) os.mknod("test.txt") 创建空文件2) open("test. ...
- Java中创建操作文件和文件夹的工具类
Java中创建操作文件和文件夹的工具类 FileUtils.java import java.io.BufferedInputStream; import java.io.BufferedOutput ...
随机推荐
- 我的Android进阶之旅------>解决错误: java.util.regex.PatternSyntaxException: Incorrect Unicode property
1.错误描述 今天使用正则表达式验证密码的时候,报了错误 java.util.regex.PatternSyntaxException: Incorrect Unicode property near ...
- SQL SERVER自动化运维系列
SQL SERVER自动化运维系列 转自:https://www.cnblogs.com/zhijianliutang/p/5001142.html 本系列为SQL SERVER自动化运维的一些操作技 ...
- Servlet中参数获取方法
在web.xml里面可以定义两种参数: 一种是全局范围的参数, 一种是servlet内的参数. web.xml里定义参数的应用举例:在做分页功能时,可以在代码中直给定pageSize的值,这样,写死在 ...
- Hbase 学习笔记5----hbase region, store, storefile和列簇的关系
The HRegionServer opens the region and creates a corresponding HRegion object. When the HRegion is o ...
- elastic job配置
zookeeper注册中心配置 1 package com.zwh.pay.account.worker; import com.dangdang.ddframe.job.reg.zookeeper. ...
- IE6/7 下:inline-block解决方案
6/IE7下:inline-block解决方案 IE6/IE7下对display:inline-block的支持性不好. 1.inline元素的display属性设置为inline-block时, ...
- 属性检测 In,hasOwnPreperty()和propertyIsEnumerable()
IN 左侧是属性名:右侧是对象名, 如果 属性是 自有属性 或者继承属性 则返回 TRUE var o={x:1,y:2} "x" in o 返回 true: hasOw ...
- CF335B
/*CF335B 这个题目的n达到50000,但是串只是有小写字母组成,所以如果字符串的长度大于2600,那么 肯定存在,所开始输入就判断如果长度大于2600,那么直接找当个字母输出100个 否则执行 ...
- Android 电池关机充电
android 电池(一):锂电池基本原理篇 android 电池(二):android关机充电流程.充电画面显示 android 电池(三):android电池系统 android电池(四):电池 ...
- 【HTML5校企公益课】第三天
1.上午2D.旋转变色的... 基本思路就是先写静态画面然后添加动画. <!--告诉浏览器该文件为网页格式--> <html> <!--网页的头部标签--> ...