当前位置:网站首页>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边栏推荐
- static的作用
- MySql——存储引擎
- Word import literature -mendeley
- The golang timer uses the stepped pit: the timer is executed once a day
- Hdu1231 maximum continuous subsequence (divide and conquer or dynamic gauge or double pointer)
- 并查集理论讲解和代码实现
- NSIS finds out whether the file exists and sets the installation path
- Database SQL practice 4. Find the last of employees in all assigned departments_ Name and first_ name
- 2022 PMP project management examination agile knowledge points (7)
- Charles- unable to grab bags and surf the Internet
猜你喜欢
CADD course learning (5) -- Construction of chemosynthesis structure with known target (ChemDraw)
How to modify the file path of Jupiter notebook under miniconda
Idea to view the source code of jar package and some shortcut keys (necessary for reading the source code)
Build your own random wallpaper API for free
Delayqueue usage and scenarios of delay queue
Explanation of parallel search set theory and code implementation
II Simple NSIS installation package
Graduation thesis project local deployment practice
Self summary of college life - freshman
Matrix and TMB package version issues in R
随机推荐
GBK error in web page Chinese display (print, etc.), solution
Rough notes of C language (1)
Idea shortcut key
Basic operation of external interrupt (keil5)
Microservice registry Nacos introduction
list. files: List the Files in a Directory/Folder
I implement queue with C I
[untitled]
Let me teach you how to develop a graphic editor
Pit record of Chmod 2 options in deepin
Play with grpc - go deep into concepts and principles
NSIS search folder
UE5热更新-远端服务器自动下载和版本检测(SimpleHotUpdate)
Apple animation optimization
Today, share the wonderful and beautiful theme of idea + website address
[idea] efficient plug-in save actions to improve your work efficiency
Oracle triggers and packages
Leetcode solution - number of islands
Graduation thesis project local deployment practice
Basic series of SHEL script (II) syntax + operation + judgment