?元旦的即定目標完成一大半,嘿嘿。接下來就是專門搞那個PHP博客了,呵呵,剛剛做了一個“文件夾重命名”的小程序,有什么作用?大家看看下面的圖就懂了,嘿嘿!
沒有命名前:
?重命名后:
?這主要是為了方便我的日常操作吧。嘿嘿。。。
廢話少說,上代碼:
?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Text.RegularExpressions; namespace 文件夾重命名 { class Program { static void Main(string[] args) { string[] ss = Directory.GetDirectories(@"D:\My Music"); // 獲取文件夾中的所有目錄 foreach (string item in ss) { // 取出的示例:g:\test\牛腩 string path = item.Substring(0, item.LastIndexOf('\\') + 1); // 獲取路徑 string dirname = item.Substring(item.LastIndexOf('\\') + 1); // 獲取目錄名 // 只重命名以中文開頭的目錄 if (Regex.IsMatch(dirname, @"^[\u4e00-\u9fa5].+")) { string new_dirname = StrToPinyin.GetChineseSpell(dirname.Substring(0, 1)).ToLower() + dirname; // 新目錄名 Directory.Move(path + dirname, path + new_dirname); // 目錄重命名 Console.WriteLine( dirname + " → " + new_dirname); } } } } }
?
?
項目下載: http://niunan.net/download/rename.7z
?
剛剛去手機店看了下,E72我們這邊竟然還沒有貨。。。郁悶。。嗯。。從這個月開始每月攢500,半年后等E72降到2000左右了就入手。。。嘿嘿。。。
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
