文件(File)
来源:互联网 发布:pslogo美工基础知识 编辑:程序博客网 时间:2024/05/28 16:25
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;namespace File类{ class Program { static void Main(string[] args) { string path = @"D:\FileTest\1707A\aa.txt"; string destPath = @"D:\FileTest\1707A\aa.txt"; //Test01(path); //Test01("王垚.txt"); //Test02(path, destPath); //Test03(path); Test04(path); } //文件创建 static void Test01(string path) { //文件的创建 if (File.Exists(path)) { Console.WriteLine("文件已经存在"); } else { //如果不存在则创建文件 File.Create(path); } } //文件的移动 和文件的重命名 static void Test02(string sourcePath,string destPath) { File.Move(sourcePath, destPath); } static void Test03(string path) { File.Delete(path); } static void Test04(string path) { //从文件读取数据的流 FileStream fs = File.Open(path, FileMode.OpenOrCreate, FileAccess.Read); byte[] byteArr = new byte[4096]; int len = 0; string destPath = @"D:\FileTest\1707A\Newaa.txt"; //写入文件的流 FileStream fsWrite = File.Open(destPath, FileMode.OpenOrCreate, FileAccess.Write); //len表示 在调用Read方法的时候 从文件中实际读取的字节数 while ((len = fs.Read(byteArr, 0, byteArr.Length)) != 0) { fsWrite.Write(byteArr, 0, len); } } }}
阅读全文
0 0
- file()拷贝文件
- File(文件类)
- PhoneGap3+ -- File(文件)
- 文件(File)
- java-File(文件)
- 读写文件(File)
- 文件(File)
- control file(控制文件)
- java文件流(File)
- file()创建文件方法
- ASCII文件ASCII File)
- 稀疏文件(Sparse File)
- File文件读写(转)
- Android文件(File)操作
- 【JAVA】文件操作(File)
- file文件(夹)处理
- FILE*文件
- 文件 File
- fwslider--属于自己的一个图片轮播插件
- POJ-2773 Happy 2006(容斥,二分,dfs)
- mobike算法挑战赛
- python爬虫学习第三十八天
- utf-8,utf-16,utf-32(浅谈)
- 文件(File)
- 范数的直觉性理解【转】
- 错误: 找不到或无法加载主类 com.test.TestIOC
- AtCoder Beginner Contest 072
- 51Nod 1066 Bash游戏
- mysql5.5、5.6统计信息采样配置及分析表
- 服务器错误代码大全
- 剑指offer_正则表达式匹配
- G- 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活