文件名唯一(A.txt => An.txt)
/// <summary>
/// 文件名唯一(A.txt => An.txt)
/// </summary>
/// <param name="fullName">文件名</param>
/// <returns></returns>
private string SingleFullName(string fullName)
{
string newfullName = fullName;
FileInfo fileInfo = new FileInfo(newfullName);
if (fileInfo.Exists)
{
int i = 1;
string fileName = fileInfo.Name;
string fileExt = fileInfo.Extension;
int extIndex = fileName.LastIndexOf(fileExt);
string name = fileName.Substring(0,extIndex);
newfullName = name + i + fileExt;
while (true)
{
fileInfo = new FileInfo(newfullName);
if (fileInfo.Exists)
{
i++;
newfullName = name + i + fileExt;
}
else
{
break;
}
}
} return newfullName;
}
文件名唯一(A.txt => An.txt)的更多相关文章
- python正则表达式从路径中取文件名出来不加后缀(txt)
正则表达式[^\\/:*?"<>|\r\n]+$ ---->取文件名包括后缀 e.g. >>>D:\PyCharm 2018.2.4\pythonWork ...
- sort命令与cat区别25.1 由于sort默认是把结果输出到标准输出,所以需要用重定向才能将结果写入文件,形如sort filename > newfile [root@shiyan a]# cat a.txt aaaaaa [root@shiyan a]# sort a.txt >c.txt ------------- 在重定向前会自动创建c.txt这个文件。 [root@shiyan
25.1 由于sort默认是把结果按照行排序后输出到标准输出,所以需要用重定向才能将结果写入文件,形如sort filename > newfile[root@shiyan a]# cat a. ...
- 还可以使用 -c 参数来显示全部内容,并标出不同之处 diff -c test2.txt test1.txt
二.实例 在test目录下存放了两个文本文件,test1.txt test2.txt . 比较这两个文件的异同. diff test1.txt test2.txt "5c5& ...
- 邮件格式(HTML/TXT),TXT为文本邮件
<?phpclass smtp{/* Public Variables */var $smtp_port;var $time_out;var $host_name;var $log_file;v ...
- Linux命令: touch tem.txt创建txt文件
touch tem.txt 创建txt文件
- Python正则表达式re.findall("[A-Za-z]([A-Za-z0-9])*[.]txt",'Abc2019.txt')的结果为什么是['9']
在<Python妙用re.sub分析正则表达式匹配过程>中老猿分析了findall函数的返回情况,老猿前一阵子在执行这个语句时: >>> re.findall(" ...
- vimdiff env.txt export.txt set.txt
1. 环境变量 简单理解了变量的概念,就很容易理解环境变量了.环境变量的作用域比自定义变量的要大,如 Shell 的环境变量作用于自身和它的子进程.在所有的 UNIX 和类 UNIX 系统中,每个进程 ...
- Qt之QTemporaryFile(文件名唯一,且可以自动删除)
简述 QTemporaryFile类是操作临时文件的I/O设备. QTemporaryFile用于安全地创建一个独一无二的临时文件.临时文件通过调用open()来创建,并且名称是唯一的(即:保证不覆盖 ...
- Python 不覆盖输入txt 读取txt
不覆盖输入: with open('1.txt','rt')as f: data=f.read() print(data+"\n") 读取txt: with open('1.txt ...
随机推荐
- ISymbol
public void Draw (IGeometry Geometry); public void QueryBoundary ( int hDC, ITransformation ...
- [GeoServer]Openlayers简单调用
Openlayers Demo: <html> <head> <title>OpenLayers Example</title> <script ...
- linux查看公网地址
curl cip.cc curl http://members.3322.org/dyndns/getip
- OC数组中文排序
-(void)sortStudentInfo { if(studentInfoArray && studentInfoArray.count > 0) { for(TWDetai ...
- Mybatis-Plugin插件学习使用方法
以下教程仅供学习使用,针对于IntelliJ Idea 15中的Mybatis Plugin插件. 作者博客中的教程:http://myoss.github.io/2016/MyBatis-Plugi ...
- 前端bower使用
Bower是一个客户端技术的软件包管理器,是由twitter推出的.它可用于搜索.安装和卸载如JavaScript.HTML.CSS之类的网络资源.其他一些建立在Bower基础之上的开发工具,如Yeo ...
- Lintcode: Remove Node in Binary Search Tree
iven a root of Binary Search Tree with unique value for each node. Remove the node with given value. ...
- Leetcode: String to Integer
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...
- JavaScript----插入视频
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Centos7 安装 Nginx
Nginx有很多版本的,下面我给个链接http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/ 下载对应当前系统版本的nginx包(packag ...