C#——文件操作类简单封装
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO; namespace ReligionServer.util {
public class FileUtil { /// <summary>
/// 根据给定路径删除文件; 如果给定路径下只有一个文件, 且要删除这个文件, 那么就将目录一起删除
/// </summary>
/// <param name="path"></param>
public static void RemoveFile(String path) {
if (File.Exists(path)) {
File.Delete(path);
DirectoryInfo directory = new FileInfo(path).Directory;
if (directory.GetFiles().Length == ) {
directory.Delete();
}
} }
}
}
C#——文件操作类简单封装的更多相关文章
- C#——图片操作类简单封装
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Dr ...
- C#——JSON操作类简单封装(DataContractJsonSerializer)
Framework版本:.Net Framework 4 使用DataContractJsonSerializer时,实体请使用注解,格式如下 1.实体使用注解,并且提供get和set的public访 ...
- VS2010/MFC编程入门之四十五(MFC常用类:CFile文件操作类)
上一节中鸡啄米讲了定时器Timer的用法,本节介绍下文件操作类CFile类的使用. CFile类概述 如果你学过C语言,应该知道文件操作使用的是文件指针,通过文件指针实现对它指向的文件的各种操作.这些 ...
- C# 文件操作类大全
C# 文件操作类大全 时间:2015-01-31 16:04:20 阅读:1724 评论:0 收藏:0 [点我收藏+] 标签: 1.创建文件夹 //usin ...
- Java文件操作类效率对比
前言 众所周知,Java中有多种针对文件的操作类,以面向字节流和字符流可分为两大类,这里以写入为例: 面向字节流的:FileOutputStream 和 BufferedOutputStream 面向 ...
- [C#] 常用工具类——文件操作类
/// <para> FilesUpload:工具方法:ASP.NET上传文件的方法</para> /// <para> FileExists:返回文件是否存在&l ...
- 文件操作类CFile
CFile file; CString str1= L"写入文件成功!"; wchar_t *str2; if (!file.Open(L"Hello.txt" ...
- asp.net文件操作类
/** 文件操作类 **/ #region 引用命名空间 using System; using System.Collections.Generic; using System.Text; usin ...
- android 文件操作类简易总结
android 文件操作类(参考链接) http://www.cnblogs.com/menlsh/archive/2013/04/02/2997084.html package com.androi ...
随机推荐
- Oracle 11G Client 客户端安装步骤(图文详解)
http://www.cnblogs.com/jiguixin/archive/2011/09/09/2172672.html 下载地址: http://download.oracle.com/otn ...
- 注册和删除Apache服务器的方法
Apache服务器的安装和卸载方法 下载Apache安装包 将Apache文件夹存在桌面或其他盘,输入cmd打开命令提示行 安装步骤:进入Apache安装目录下的bin目录: cd C:\Us ...
- Delphi Live Bindings 初探
Delphi Live Bindings 初探 Live Bindings,顾名思义,动态绑定. 1.绑定前: 2.点击数据源: 3.绑定连线:点击 蓝色区域, 按住 鼠标左键,一直移动到绿色区域,然 ...
- stringstream读入每行数据
做了下阿里的编程测试题,就30分钟,不是正常的输入输入,直接给一个数组作为输入. 于是带想题和处理数据花了20分钟,最后10分钟搞一个dij模版, 竟然只过了66%,应该是我数组开小了. 题目数据量没 ...
- LeetCode——Kth Largest Element in an Array
Description: Find the kth largest element in an unsorted array. Note that it is the kth largest elem ...
- 【BZOJ5099】[POI2018]Pionek 几何+双指针
[BZOJ5099][POI2018]Pionek Description 在无限大的二维平面的原点(0,0)放置着一个棋子.你有n条可用的移动指令,每条指令可以用一个二维整数向量表示.每条指令最多只 ...
- 如何设置Eclipse工作区默认编辑宽度
1)打开Window => Preferences窗口 2)打开Formatter属性页从Java => CodeStyle => Formatter 3) 单击New创建一个自己 ...
- java类的成员初始化顺序和初始化块知识
java类的成员初始化顺序和初始化块知识 转自:http://blog.csdn.net/lgfeng218/article/details/7606735 属性.方法.构造方法和自由块都是类中的成员 ...
- idea的svn插件中compare with the same repository version和compare with latest repository version的区别?
Idea的svn插件中compare with the same repository version和compare with latest repository version的区别? 1.com ...
- Python 使用 Matplotlib 做图时,如何画竖直和水平的分割线或者点画线或者直线?
作者:看看链接:https://www.zhihu.com/question/21929761/answer/164975814 可以使用: vlines(x, ymin, ymax) hlines( ...