洞察如何通过FinClip解决方案提升微信小程序在电脑端的性能与安全性
650
2022-09-11
C# copy files from source directory to destination file and rename repeated files and does not overr(c反应蛋白高说明什么)
static void CopyFiles()
{
string sourceDir = @"D:\C\ll";
string destDir = @"D:\LL";
if (!Directory.Exists(destDir))
{
Directory.CreateDirectory(destDir);
}
string[] mp3Files= Directory.GetFiles(sourceDir, "*.mp3", SearchOption.AllDirectories);
if(mp3Files!=null && mp3Files.Any())
{
Dictionary
List
foreach (string mp3 in mp3Files)
{
string mp3FileName = Path.GetFileName(mp3);
string newMp3FileName = Path.GetFileName(mp3);
if (dic.ContainsKey(mp3FileName))
{
string guid = Guid.NewGuid().ToString().Substring(0, 6);
newMp3FileName = Path.GetFileNameWithoutExtension(mp3FileName) + guid + ".mp3";
dic.Add(newMp3FileName, newMp3FileName);
string repeatedMsg = $"mp3:{mp3},newMp3FileName:{newMp3FileName}";
repeatedList.Add(repeatedMsg);
}
else
{
dic.Add(mp3FileName, mp3FileName);
}
string newMp3FullName = Path.Combine(destDir, newMp3FileName);
File.Copy(mp3, newMp3FullName, false);
Console.WriteLine($"oldmp3:{mp3},newMp3FullName:{newMp3FullName}");
}
dic = null;
Console.WriteLine($"\n\n There are {repeatedList.Count} Repeated Msg:");
repeatedList.ForEach(x =>
{
Console.WriteLine(x);
});
}
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~