当前位置:网站首页>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边栏推荐
- Nombre - 1. Création de tableaux
- "Source code interpretation" famous programmer TJ's only library
- String alignment method, self use, synthesis, newrlcjust
- I 用c I 实现队列
- Basic operation of external interrupt (keil5)
- CADD course learning (5) -- Construction of chemosynthesis structure with known target (ChemDraw)
- Explanation of parallel search set theory and code implementation
- msys2
- How to modify the file path of Jupiter notebook under miniconda
- 行测--资料分析--fb--高照老师
猜你喜欢

Line test -- data analysis -- FB -- teacher Gao Zhao

Latex notes

Oracle triggers and packages

Don't confuse the use difference between series / and / *

How to deal with excessive memory occupation of idea and Google browser

Leetcode solution - number of islands

SQL JOINS

Shadowless cloud desktop - online computer

Tshydro tool

Rough notes of C language (1)
随机推荐
Qu'est - ce que l'hydroxyde de sodium?
Opendrive record
String alignment method, self use, synthesis, newrlcjust
Typecho adds Baidu collection (automatic API submission plug-in and crawler protocol)
What is sodium hydroxide?
Simple operation with independent keys (hey, a little fancy) (keil5)
UE5热更新-远端服务器自动下载和版本检测(SimpleHotUpdate)
Reading literature sorting 20220104
Install deeptools in CONDA mode
Microservice registry Nacos introduction
Numpy——1. Creation of array
Deepin get file (folder) list
Process (P) runs, and idle is different from pycharm
Pit record of Chmod 2 options in deepin
Butterfly theme beautification - Page frosted glass effect
Tshydro tool
What is Bezier curve? How to draw third-order Bezier curve with canvas?
[untitled]
repo. conda. An example of COM path error
Oracle code use