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 ...
随机推荐
- VS2015编译GEOS3.5.1源码
官网下载下来的geos3.5.1,执行CMakeLists.txt,发现会报错:GenerateSourceGroups 去github上搜索geos,然后去\cmake\modules目录下复制一份 ...
- Effective C++ —— 定制new和delete(八)
STL容器所使用的heap内存是由容器所拥有的分配器对象管理,不是被new和delete直接管理.本章并不讨论STL分配器. 条款49 : 了解new-handler的行为 当operator new ...
- 96、facebook Fresco框架库源使用(转载)
各个属性详情:http://blog.csdn.net/y1scp/article/details/49245535 开源项目链接 facebook Fresco仓库:git clone https: ...
- tomcat日志保存在哪里?
tomcat目录下的logs文件夹下.有个catalina.20xx-xx-xx.log
- poj_3468 线段树
题目大意 一个数列,每次操作可以是将某区间数字都加上一个相同的整数,也可以是询问一个区间中所有数字的和.(这里区间指的是数列中连续的若干个数)对每次询问给出结果. 思路 对于区间的查找更新操作,可以考 ...
- activemq 实战三 了解连接器的URI-Understanding connector URIs
Before discussing the details of connectors and their role in the overall ActiveMQ architecture, it’ ...
- LeetCode——Single Number III
Description: Given an array of numbers nums, in which exactly two elements appear only once and all ...
- hdu5411 CRB and Puzzle[矩阵优化dp]
CRB and Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- ansible的入门级使用
author: headsen chen date: 2018-08-02 11:46:35 1,ansible的安装 yum install epel-release yum -y i ...
- MySQL Server has gone away报错原因汇总分析(转自:http://cenalulu.github.io/mysql/mysql-has-gone-away/)
原因1. MySQL 服务宕了 判断是否属于这个原因的方法很简单,执行以下命令,查看mysql的运行时长 $ mysql -uroot -p -e "show global status l ...