C# 文件相关操作
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO; namespace CreateFile
{
class Program
{
static void Main(string[] args)
{
string path = @"f:\MyDir\test\test";
string target = @"f:\TestDir";
Directory.CreateDirectory(path);
try
{
// Determine whether the directory exists.
if (!Directory.Exists(path))
{
// Create the directory it does not exist.
Directory.CreateDirectory(path);
} if (Directory.Exists(target))
{
// Delete the target to ensure it is not there.
Directory.Delete(target, true);
} // Move the directory.
Directory.Move(path, target); // Create a file in the directory.
File.CreateText(target + @"\myfile.txt"); // Count the files in the target directory.
Console.WriteLine("The number of files in {0} is {1}",
target, Directory.GetFiles(target).Length);
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
} Console.ReadKey();
}
}
}
C# 文件相关操作的更多相关文章
- Git基本命令 -- 基本工作流程 + 文件相关操作
可以先找一个已经被git管理的项目, 我就使用这个项目吧: https://github.com/solenovex/ID3-Editor 基本工作流程 克隆以后呢, 进入该目录查看一下状态: 然后添 ...
- python文件相关操作
Python文件相关操作 打开文件 打开文件,采用open方法,会将文件的句柄返回,如下: f = open('test_file.txt','r',encoding='utf-8') 在上面的代码中 ...
- VC++文件相关操作的函数封装实现
在开发编译工具中,需要用到文件的相关操作,于是就封装了相关的函数实现: //判断文件是否存在 BOOL FileIsExist(CString strFileName) { CFileFind fin ...
- 【原创】Linux基础之gz文件相关操作
gz文件不需要解压即可进行相关操作 $ zcat test.log.gz $ zmore test.log.gz $ zless test.log.gz $ zgrep '1.2.3.4' test. ...
- Nodejs文件相关操作
欢迎关注我的博客我在马路边 适用人群 本文适用于刚接触Node的小白,毕竟我也是小白,大佬请绕行. Node文件操作 在实际开发中遇到很多有关文件及文件夹的操作,比如创建.删除文件及文件夹,文件拷贝. ...
- linux学习笔记一----------文件相关操作
一.目录结构 二.文件管理操作命令(有关文件夹操作,使用Tab键自动补全文件名(如果多个默认第一个)) 1.ls 查看目录信息:ls -l 查看目录详细信息(等价于ll 某些系统不支持) 2.pwd ...
- UWP中的文件相关操作
最近开始做UWP开发,图省事儿就把自己之前一个Winform项目的一部分代码拷贝到了新写的UWP项目中来.整出了一些幺蛾子,下面做一个记录. 首先提一个重点就是:UWP里关于文件的操作尽量用Stora ...
- UNIX高级环境编程(5)Files And Directories - 文件相关时间,目录文件相关操作
1 File Times 每个文件会维护三个时间字段,每个字段代表的时间都不同.如下表所示: 字段说明: st_mtim(the modification time)记录了文件内容最后一次被修改的时 ...
- 关于php的ini文件相关操作函数浅析
在小公司,特别是创业型公司,整个服务器的搭建一般也是我们 PHP 开发工程师的职责之一.其中,最主要的一项就是要配置好服务器的 php.ini 文件.一些参数会对服务器的性能产生深远的影响,而且也有些 ...
- c语言中文件相关操作
一 .首先介绍一下数据文件的类型: 1.二进制文件(映像文件):在内存中以二进制形式存取. 2.文本文件(ascii文件):以ascii码形式存取的文件. 通俗的讲,在Mac下,你把一个文件丢进记事本 ...
随机推荐
- Java工具类 Apache Commons:commons-lang
Commons Lang The standard Java libraries fail to provide enough methods for manipulation of its core ...
- js逻辑与,或,非
[转,未整理] 1.逻辑非(!) 如果一个操作数是一个对象,返回true; 如果一个操作数是一个空字符串,返回false; 如果一个操作数是一个非空字符串,返回false; 如果一个操作数是一个数值0 ...
- perl学习笔记(3)—— 坑
(1)用perl来ls一个目录: 写perl的时候,经常要调用到系统命令,perl有很多等价的函数可以用,但是,不小心任性了,就想用system来实现了,好吧,来个ls把,列出指定的一个目录,直接上代 ...
- Slony-I的删除:
接前篇:http://www.cnblogs.com/gaojian/p/3196244.html 简单的Slony-I设置实例 如何删除slony相关的内容呢. 我再另外找一台机器,安装slony, ...
- Codeforces Round #337 (Div. 2) B. Vika and Squares 贪心
B. Vika and Squares 题目连接: http://www.codeforces.com/contest/610/problem/B Description Vika has n jar ...
- hdu 5264 pog loves szh I 水题
pog loves szh I Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- C# 的时间戳转换
/// <summary> /// 时间戳转为C#格式时间 /// </summary> /// <param name="timeStamp"> ...
- oc-32-@property示例
Goods.h #import <Foundation/Foundation.h> typedef struct{ int year; int month; int day; } MyDa ...
- 创建MS Office 和 WPS 兼容插件
在工作中我们要实现一个功能,需要创建MS Office 和 WPS 兼容插件,也就是创建一个DLL,可以同时兼容office和wps.这样带来的好处就是只需要维护同一份代码,大大降低维护的工作! 1. ...
- Linux 2.4调度系统分析--转
http://www.ibm.com/developerworks/cn/linux/kernel/l-k24sch/index.html 杨沙洲 (pubb@163.net)国防科技大学计算机学院 ...