当前位置:网站首页>Rename directory in C [closed] - renaming a directory in C [closed]
Rename directory in C [closed] - renaming a directory in C [closed]
2022-07-05 07:37:00 【French red wine sweet】
problem :
I couldn't find a DirectoryInfo.Rename(To) or FileInfo.Rename(To) method anywhere. I can't find it anywhere DirectoryInfo.Rename(To) or FileInfo.Rename(To) Method .So, I wrote my own and I'm posting it here for anybody to use if they need it, because let's face it : the MoveTo methods are overkill and will always require extra logic if you just want to rename a directory or file : therefore , I wrote my own , I post it here , For anyone to use , If they need it , Because let's face it :MoveTo The method is excessive , If you just want to rename a directory or file , Additional logic will always be needed :
public static class DirectoryExtensions{ public static void RenameTo(this DirectoryInfo di, string name) { if (di == null) { throw new ArgumentNullException("di", "Directory info to rename cannot be null"); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("New name cannot be null or blank", "name"); } di.MoveTo(Path.Combine(di.Parent.FullName, name)); return; //done }}Solution :
Reference resources : https://stackoom.com/en/question/8UWl边栏推荐
- Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required
- Daily Practice:Codeforces Round #794 (Div. 2)(A~D)
- 大学生活的自我总结-大一
- Apple input method optimization
- The number of occurrences of numbers in the offer 56 array (XOR)
- The golang timer uses the stepped pit: the timer is executed once a day
- 611. 有效三角形的个数
- Simple operation of running water lamp (keil5)
- Miracast技术详解(一):Wi-Fi Display
- Function of static
猜你喜欢

Set theory of Discrete Mathematics (I)

Microservice registry Nacos introduction

SQL JOINS

Word import literature -mendeley

I 用c I 实现队列

Play with grpc - go deep into concepts and principles

Openxlsx field reading problem

Numpy——1.数组的创建

Rough notes of C language (1)

Hdu1231 maximum continuous subsequence (divide and conquer or dynamic gauge or double pointer)
随机推荐
Logistic regression: the most basic neural network
Esmini longspeedaction modification
Ugnx12.0 initialization crash, initialization error (-15)
UE5热更新-远端服务器自动下载和版本检测(SimpleHotUpdate)
UNIX commands often used in work
Mouse click fireworks explosion effect
Practical application cases of digital Twins - fans
Nombre - 1. Création de tableaux
Idea shortcut key
Latex notes
Idea common settings
ORACLE CREATE SEQUENCE,ALTER SEQUENCE,DROP SEQUENCE
Typecho adds Baidu collection (automatic API submission plug-in and crawler protocol)
cygwin
NSIS finds out whether the file exists and sets the installation path
Opendrive record
arcgis_ spatialjoin
CADD课程学习(6)-- 获得已有的虚拟化合物库(Drugbank、ZINC)
(top) pretty girl binary color code portal
Matrix and TMB package version issues in R