C#初学者,自己做了一个批量小说下重命名的小程序

stromlord 2016-10-29 01:28:57
加精
初学C#,因为平时很喜欢看小说,一时兴起,做了这个。因为是初学者,做得很简陋,但自认为还可以。
可以对笔下文学,请看小说上的小说进行批量重命名(我只知道这两个,如果还有其他好的,请务必告诉我)
path:http://pan.baidu.com/s/1hslvBHM
...全文
4236 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
猴头 2016-11-16
  • 打赏
  • 举报
回复
juno_393 2016-11-15
  • 打赏
  • 举报
回复
做了2年的Delphi,想抽时间接触一下C#,麻烦推荐点资料
Alice517013237 2016-11-15
  • 打赏
  • 举报
回复
作为一名初级产品经理,完全不懂。。。因为看到是小说,疯狂的小说迷表示感兴趣。。。
ganyunan 2016-11-14
  • 打赏
  • 举报
回复
weikeli19 2016-11-13
  • 打赏
  • 举报
回复
我也想学。。。。。。。。。。。。。。。。。。
milecheng 2016-11-10
  • 打赏
  • 举报
回复



请问下 为什么说调试错了啊,我用的是TEXT 请问 要求有格式吗 怎么个使用方法 非常感谢
  • 打赏
  • 举报
回复
吾乃小小师 2016-11-09
  • 打赏
  • 举报
回复
好厉害
正怒月神 2016-11-04
  • 打赏
  • 举报
回复
希望继续保持编程的热情, 赞一个
wx_1125 2016-11-04
  • 打赏
  • 举报
回复
我也要学c#啦~
_findmyway 2016-10-31
  • 打赏
  • 举报
回复
学习一下 目前我也在看C#
threenewbee 2016-10-30
  • 打赏
  • 举报
回复
感谢lz的分享。给你推荐了下
_明月 2016-10-30
  • 打赏
  • 举报
回复
引用 5 楼 caozhy 的回复:
感谢lz的分享。给你推荐了下
问一下曹老师和楼主,你们是如何学习C#的? 亦或者分享一下自己学习IT这个行业的专业知识的学习方法?谢谢
我是飞云 2016-10-29
  • 打赏
  • 举报
回复
效率这东西随着不同的阶段有不同的看法,所以暂时应该只看重“功能”,也就是解决方案。 PS:名称空间和其他的名字定义尽量形成一套习惯,比如大驼峰。
Justin-Liu 2016-10-29
  • 打赏
  • 举报
回复
没什么问题 字符串那里,用string.Format连接
stromlord 2016-10-29
  • 打赏
  • 举报
回复
这是界面
stromlord 2016-10-29
  • 打赏
  • 举报
回复
如果有大神愿意,帮我看看怎么改的更好

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace 修改小说文件名
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void MIOpen_Click(object sender, RoutedEventArgs e)
{

//获取文件地址
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "选择文件";
ofd.Multiselect = true;
ofd.Filter = "文本文档|*.txt";
if (ofd.ShowDialog() == false)
{
return;
}
List<string> NovelList = new List<string>();
foreach (string File in ofd.FileNames)
{
NovelList.Add(File);
NameChanged(File);
}
NovelList.Add("重命名完成");
LNovels.ItemsSource = NovelList;
}
static void NameChanged(String FileName)
{
String[] line = new String[5];
string NewName;
//获取文件名
using (FileStream fileStream = File.OpenRead(FileName))
{
using (StreamReader NovelName = new StreamReader(fileStream, Encoding.Default))//StreamReader读取中文时出现乱码
{
for (int i = 0; i < 5; i++)
{
line[i] = NovelName.ReadLine();

}
}
}

//重命名
DirectoryInfo di = Directory.GetParent(FileName); //获取父系文件夹名
if (line[0].Contains("笔下文学"))
{
NewName = di.ToString() + "\\" + line[3].Substring(1, line[3].Length - 2) + ".txt";//生成新文件名
}
else if (line[4].Contains("http://www.qingkan520.com/"))
{
NewName = di.ToString() + "\\" + line[0].Substring(1, line[0].Length - 2) + ".txt";
}
else
{
NewName = FileName;
}
File.Move(FileName, NewName);
}

}
}



7,765

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧