当前位置:网站首页>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边栏推荐
- R language learning notes 1
- Apple animation optimization
- Line test -- data analysis -- FB -- teacher Gao Zhao
- And play the little chestnut of dynamic agent
- Qu'est - ce que l'hydroxyde de sodium?
- Simple operation with independent keys (hey, a little fancy) (keil5)
- What is Bezier curve? How to draw third-order Bezier curve with canvas?
- cygwin
- Apple input method optimization
- UNIX commands often used in work
猜你喜欢

Ue5 hot update - remote server automatic download and version detection (simplehotupdate)

HDU1231 最大连续子序列(分治or动规or双指针)

Matrix and TMB package version issues in R

Unforgettable summary of 2021

借助 Navicat for MySQL 软件 把 不同或者相同数据库链接中的某数据库表数据 复制到 另一个数据库表中

Close of office 365 reading

大学生活的自我总结-大一

Thunderbird tutorial \ easy to use mail client

Machine learning Seaborn visualization

Detailed explanation of miracast Technology (I): Wi Fi display
随机推荐
Miracast技术详解(一):Wi-Fi Display
deepin 20 kivy unable to get a window, abort
QT small case "addition calculator"
repo. conda. An example of COM path error
Explanation of parallel search set theory and code implementation
Line test -- data analysis -- FB -- teacher Gao Zhao
Anaconda pyhton multi version switching
Apple input method optimization
Matrix keyboard scan (keil5)
DataGrid offline installation of database driver
Numpy——1.數組的創建
golang定时器使用踩的坑:定时器每天执行一次
Apple terminal skills
Esmini longspeedaction modification
How to delete the virus of inserting USB flash disk copy of shortcut to
[idea] common shortcut keys
(tool use) how to make the system automatically match and associate to database fields by importing MySQL from idea and writing SQL statements
Today, share the wonderful and beautiful theme of idea + website address
611. Number of effective triangles
[MySQL] database knowledge record