当前位置: 首页 > news >正文

临海网站开发公司物流企业网站建设

临海网站开发公司,物流企业网站建设,旅游业网站建设,电子商务是干什么的工资一般多少目录 工具介绍 工具背景 4个文件介绍 CopyTheSpecifiedSuffixFiles.exe.config DataSave.txt 拷贝的存储方式 文件夹介绍 源文件夹 目标文件夹 结果 使用 *.mp4 使用 *.* 重名时坚持拷贝 可能的报错 C#代码如下 Form1.cs Form1.cs设计 APP.config Program.c…目录 工具介绍 工具背景 4个文件介绍 CopyTheSpecifiedSuffixFiles.exe.config DataSave.txt 拷贝的存储方式 文件夹介绍 源文件夹 目标文件夹 结果 使用 *.mp4 使用 *.* 重名时坚持拷贝 可能的报错 C#代码如下 Form1.cs Form1.cs设计 APP.config Program.cs Form1.Designer.cs 工具介绍 工具背景 你知道为啥我今天突然写这个吗 我昨天下载视频发现他全部都是分文件夹存的一个一个开太麻烦了呢今天就写了这个哈哈哈全部拿出来一下子就能全部添加到播放列表了 只拷贝指定文件后缀的东西到新的文件夹里面不管你原来的文件夹里面都多少个子文件夹都能给你把需要的文件复制出来但是不会复制子文件夹即不会复制原来的存储结构我特意这么做的 你上次选的这四个选项他会记住后面再打开就是上次的位置。 4个文件介绍 CopyTheSpecifiedSuffixFiles.exe.config 相信你一眼就能看出来这个是干什么的了没错这个是这个软件的默认配置当然你也可以在DataSave.txt中改动。 DataSave.txt 一开始是没有的后面自动生成的哦~ 拷贝的存储方式 1. 保留原文件保留目标文件夹的重名文件 2. 替换文件替换目标文件夹的重名文件 3. 保留并自动增加文件名称拷贝的时候后面会在后面加上_1区分如下图 只拷贝指定文件后缀的东西到新的文件夹里面不管你原来的文件夹里面都多少个子文件夹都能给你把需要的文件复制出来但是不会复制子文件夹即不会复制原来的存储结构我特意这么做的重要的事情说两遍为啥不说三遍哈哈哈 因为没有因为 0.o 文件夹介绍 源文件夹 目标文件夹 结果 使用 *.mp4 使用 *.* 重名时坚持拷贝 可能的报错 因为你缺失这个东西下载下就行了一个底层的小玩意儿 C#代码如下 不想一点点弄可以直接下载上传的资源。 Form1.cs using System; using System.Configuration; using System.Diagnostics; using System.IO; using System.Windows.Forms;namespace CopyTheSpecifiedSuffixFiles {public partial class frmCopyFiles : Form{public frmCopyFiles(){InitializeComponent();}private Stopwatch stopwatch new Stopwatch();public void btnCopy_Click(object sender, EventArgs e){// 创建 Stopwatch 对象stopwatch new Stopwatch();// 开始计时stopwatch.Start();lblResDesc.ForeColor System.Drawing.Color.Red;lblResDesc.Text 正在拷贝请稍等...;this.Refresh();string sourceFolderPath txtSourceFolderPath.Text;string destinationFolderPath txtDestinationFolderPath.Text;// 检查文件夹是否存在不存在直接创建空的文件夹if (!Directory.Exists(sourceFolderPath)) Directory.CreateDirectory(sourceFolderPath);if (!Directory.Exists(destinationFolderPath)) Directory.CreateDirectory(destinationFolderPath);// 编辑txt文件并写入两个字符串string filePath DataSave.txt;// 写入文件using (StreamWriter writer new StreamWriter(filePath)){writer.WriteLine(sourceFolderPath);writer.WriteLine(destinationFolderPath);writer.WriteLine(cboSuffixSelect.Text);writer.WriteLine(txtSuffixInfo.Text);writer.Flush(); // 刷新缓冲区确保数据被写入文件}// 拷贝目标文件夹内部所有的.mp4文件至新文件夹中CopyFiles(sourceFolderPath, destinationFolderPath);lblResDesc.ForeColor System.Drawing.Color.Green;lblResDesc.Text 文件拷贝完成;// 停止计时stopwatch.Stop();// 获取耗时TimeSpan elapsedTime stopwatch.Elapsed;MessageBox.Show(文件拷贝完成\n 程序执行耗时: Math.Round(elapsedTime.TotalMilliseconds / 1000, 1) 秒);}// 递归拷贝目标文件夹及其子文件夹中的所有.mp4文件至新文件夹中public void CopyFiles(string sourceFolderPath, string destinationFolderPath){int fileCount 1; // 记录已存在的文件数量// 获取文件列表string[] files Directory.GetFiles(sourceFolderPath, txtSuffixInfo.Text);foreach (string file in files){string fileName Path.GetFileName(file);string destinationFilePath Path.Combine(destinationFolderPath, fileName);if (File.Exists(destinationFilePath)){string input cboSuffixSelect.Text;if (input 1. 保留原文件){continue; // 保留原文件跳过拷贝}else if (input 2. 替换文件){File.Copy(file, destinationFilePath, true); // 替换文件}else if (input 3. 保留并自动增加文件名称){string fileNameWithoutExtension Path.GetFileNameWithoutExtension(fileName);string fileExtension Path.GetExtension(fileName);string newFileName ${fileNameWithoutExtension}_{fileCount}{fileExtension};fileCount;destinationFilePath Path.Combine(destinationFolderPath, newFileName);try{File.Copy(file, destinationFilePath); // 拷贝文件}catch (Exception e){MessageBox.Show(e.Message);}}else{MessageBox.Show(请输入正确的选项);Application.Exit();}}else{File.Copy(file, destinationFilePath); // 拷贝文件}}string[] subDirectories Directory.GetDirectories(sourceFolderPath);foreach (string subDirectory in subDirectories){CopyFiles(subDirectory, destinationFolderPath);}}public void Form1_Load(object sender, EventArgs e){// 添加选项到 ComboBoxcboSuffixSelect.Items.Add(1. 保留原文件);cboSuffixSelect.Items.Add(2. 替换文件);cboSuffixSelect.Items.Add(3. 保留并自动增加文件名称);// 设置默认选中项cboSuffixSelect.SelectedIndex 2;// 创建一个txt文件并写入两个字符串string filePath DataSave.txt;// 检查文件是否存在if (!File.Exists(filePath)){// 创建文件并写入初始内容using (StreamWriter writer new StreamWriter(filePath)){writer.WriteLine(ConfigurationManager.AppSettings[SourceFolderPath]);writer.WriteLine(ConfigurationManager.AppSettings[DestinationFolderPath]);writer.WriteLine(ConfigurationManager.AppSettings[CopyStytle]);writer.WriteLine(ConfigurationManager.AppSettings[SuffixType]);}}// 读取文件并输出每行内容using (StreamReader reader new StreamReader(filePath)){txtSourceFolderPath.Text reader.ReadLine(); // 读取第一行内容txtDestinationFolderPath.Text reader.ReadLine(); // 读取第二行内容cboSuffixSelect.Text reader.ReadLine();txtSuffixInfo.Text reader.ReadLine();}}public void btnChooseSourcePath_Click(object sender, EventArgs e){FolderBrowserDialog folderBrowserDialog new FolderBrowserDialog();// 设置对话框的描述文本folderBrowserDialog.Description 选择文件夹;// 显示对话框并获取用户选择的路径DialogResult result folderBrowserDialog.ShowDialog();if (result DialogResult.OK){string selectedFolderPath folderBrowserDialog.SelectedPath;txtSourceFolderPath.Text selectedFolderPath;}}public void btnChooseTargetPath_Click(object sender, EventArgs e){FolderBrowserDialog folderBrowserDialog new FolderBrowserDialog();folderBrowserDialog.Description 选择文件夹;DialogResult result folderBrowserDialog.ShowDialog();if (result DialogResult.OK){string selectedFolderPath folderBrowserDialog.SelectedPath;txtDestinationFolderPath.Text selectedFolderPath;}}private void btnClose_Click(object sender, EventArgs e){Application.Exit();}} }Form1.cs设计 APP.config ?xml version1.0 encodingutf-8 ? configurationappSettings!--源文件夹--add keySourceFolderPath valueD:\Code_VS2019\测试文件夹/!--目标文件夹--add keyDestinationFolderPath valueC:\Users\xxxxx\Desktop\拷贝结果/!--复制方式--add keyCopyStytle value3. 保留并自动增加文件名称/!--后缀格式--add keySuffixType value*.mp4//appSettingsstartupsupportedRuntime versionv4.0 sku.NETFramework,Versionv4.5 //startup /configuration Program.cs using System; using System.Windows.Forms;namespace CopyTheSpecifiedSuffixFiles {static class Program{/// summary/// 应用程序的主入口点。/// /summary[STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new frmCopyFiles());}} }Form1.Designer.cs namespace CopyTheSpecifiedSuffixFiles {partial class frmCopyFiles{/// summary/// 必需的设计器变量。/// /summaryprivate System.ComponentModel.IContainer components null;/// summary/// 清理所有正在使用的资源。/// /summary/// param namedisposing如果应释放托管资源为 true否则为 false。/paramprotected override void Dispose(bool disposing){if (disposing (components ! null)){components.Dispose();}base.Dispose(disposing);}#region Windows 窗体设计器生成的代码/// summary/// 设计器支持所需的方法 - 不要修改/// 使用代码编辑器修改此方法的内容。/// /summaryprivate void InitializeComponent(){this.btnCopy new System.Windows.Forms.Button();this.cboSuffixSelect new System.Windows.Forms.ComboBox();this.txtSourceFolderPath new System.Windows.Forms.TextBox();this.txtDestinationFolderPath new System.Windows.Forms.TextBox();this.lblSourceDesc new System.Windows.Forms.Label();this.lblTargetDesc new System.Windows.Forms.Label();this.btnChooseSourcePath new System.Windows.Forms.Button();this.btnChooseTargetPath new System.Windows.Forms.Button();this.lblSaveSelectDesc new System.Windows.Forms.Label();this.lblSuffixSelectDesc new System.Windows.Forms.Label();this.txtSuffixInfo new System.Windows.Forms.TextBox();this.lblSuffixInfoDesc new System.Windows.Forms.Label();this.lblResDesc new System.Windows.Forms.Label();this.btnClose new System.Windows.Forms.Button();this.SuspendLayout();// // btnCopy// this.btnCopy.AutoSize true;this.btnCopy.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnCopy.Location new System.Drawing.Point(494, 52);this.btnCopy.Name btnCopy;this.btnCopy.Size new System.Drawing.Size(107, 52);this.btnCopy.TabIndex 0;this.btnCopy.Text 拷贝;this.btnCopy.UseVisualStyleBackColor true;this.btnCopy.Click new System.EventHandler(this.btnCopy_Click);// // cboSuffixSelect// this.cboSuffixSelect.Font new System.Drawing.Font(宋体, 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.cboSuffixSelect.FormattingEnabled true;this.cboSuffixSelect.Location new System.Drawing.Point(107, 148);this.cboSuffixSelect.Name cboSuffixSelect;this.cboSuffixSelect.Size new System.Drawing.Size(198, 22);this.cboSuffixSelect.TabIndex 1;// // txtSourceFolderPath// this.txtSourceFolderPath.Location new System.Drawing.Point(107, 40);this.txtSourceFolderPath.Name txtSourceFolderPath;this.txtSourceFolderPath.Size new System.Drawing.Size(302, 21);this.txtSourceFolderPath.TabIndex 2;// // txtDestinationFolderPath// this.txtDestinationFolderPath.Location new System.Drawing.Point(107, 94);this.txtDestinationFolderPath.Name txtDestinationFolderPath;this.txtDestinationFolderPath.Size new System.Drawing.Size(300, 21);this.txtDestinationFolderPath.TabIndex 3;// // lblSourceDesc// this.lblSourceDesc.AutoSize true;this.lblSourceDesc.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.lblSourceDesc.Location new System.Drawing.Point(27, 42);this.lblSourceDesc.Name lblSourceDesc;this.lblSourceDesc.Size new System.Drawing.Size(76, 16);this.lblSourceDesc.TabIndex 4;this.lblSourceDesc.Text 源文件夹;// // lblTargetDesc// this.lblTargetDesc.AutoSize true;this.lblTargetDesc.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.lblTargetDesc.Location new System.Drawing.Point(12, 96);this.lblTargetDesc.Name lblTargetDesc;this.lblTargetDesc.Size new System.Drawing.Size(93, 16);this.lblTargetDesc.TabIndex 5;this.lblTargetDesc.Text 目标文件夹;// // btnChooseSourcePath// this.btnChooseSourcePath.AutoSize true;this.btnChooseSourcePath.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnChooseSourcePath.Location new System.Drawing.Point(415, 37);this.btnChooseSourcePath.Name btnChooseSourcePath;this.btnChooseSourcePath.Size new System.Drawing.Size(52, 26);this.btnChooseSourcePath.TabIndex 6;this.btnChooseSourcePath.Text 选择;this.btnChooseSourcePath.UseVisualStyleBackColor true;this.btnChooseSourcePath.Click new System.EventHandler(this.btnChooseSourcePath_Click);// // btnChooseTargetPath// this.btnChooseTargetPath.AutoSize true;this.btnChooseTargetPath.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnChooseTargetPath.Location new System.Drawing.Point(415, 91);this.btnChooseTargetPath.Name btnChooseTargetPath;this.btnChooseTargetPath.Size new System.Drawing.Size(52, 26);this.btnChooseTargetPath.TabIndex 7;this.btnChooseTargetPath.Text 选择;this.btnChooseTargetPath.UseVisualStyleBackColor true;this.btnChooseTargetPath.Click new System.EventHandler(this.btnChooseTargetPath_Click);// // lblSaveSelectDesc// this.lblSaveSelectDesc.AutoSize true;this.lblSaveSelectDesc.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.lblSaveSelectDesc.Location new System.Drawing.Point(27, 151);this.lblSaveSelectDesc.Name lblSaveSelectDesc;this.lblSaveSelectDesc.Size new System.Drawing.Size(76, 16);this.lblSaveSelectDesc.TabIndex 8;this.lblSaveSelectDesc.Text 存储方式;// // lblSuffixSelectDesc// this.lblSuffixSelectDesc.AutoSize true;this.lblSuffixSelectDesc.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.lblSuffixSelectDesc.Location new System.Drawing.Point(27, 205);this.lblSuffixSelectDesc.Name lblSuffixSelectDesc;this.lblSuffixSelectDesc.Size new System.Drawing.Size(76, 16);this.lblSuffixSelectDesc.TabIndex 9;this.lblSuffixSelectDesc.Text 填入后缀;// // txtSuffixInfo// this.txtSuffixInfo.Location new System.Drawing.Point(107, 203);this.txtSuffixInfo.Name txtSuffixInfo;this.txtSuffixInfo.Size new System.Drawing.Size(131, 21);this.txtSuffixInfo.TabIndex 10;// // lblSuffixInfoDesc// this.lblSuffixInfoDesc.AutoSize true;this.lblSuffixInfoDesc.Font new System.Drawing.Font(宋体, 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.lblSuffixInfoDesc.ForeColor System.Drawing.Color.DodgerBlue;this.lblSuffixInfoDesc.Location new System.Drawing.Point(270, 206);this.lblSuffixInfoDesc.Name lblSuffixInfoDesc;this.lblSuffixInfoDesc.Size new System.Drawing.Size(122, 14);this.lblSuffixInfoDesc.TabIndex 11;this.lblSuffixInfoDesc.Text 填入格式*.mp4;// // lblResDesc// this.lblResDesc.AutoSize true;this.lblResDesc.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.lblResDesc.ForeColor System.Drawing.Color.Green;this.lblResDesc.Location new System.Drawing.Point(338, 151);this.lblResDesc.Name lblResDesc;this.lblResDesc.Size new System.Drawing.Size(263, 16);this.lblResDesc.TabIndex 12;this.lblResDesc.Text 请选择相应参数并点击拷贝按钮;// // btnClose// this.btnClose.AutoSize true;this.btnClose.Font new System.Drawing.Font(宋体, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnClose.Location new System.Drawing.Point(494, 184);this.btnClose.Name btnClose;this.btnClose.Size new System.Drawing.Size(107, 52);this.btnClose.TabIndex 13;this.btnClose.Text 关闭;this.btnClose.UseVisualStyleBackColor true;this.btnClose.Click new System.EventHandler(this.btnClose_Click);// // frmCopyFiles// this.AutoScaleDimensions new System.Drawing.SizeF(6F, 12F);this.AutoScaleMode System.Windows.Forms.AutoScaleMode.Font;this.ClientSize new System.Drawing.Size(614, 258);this.Controls.Add(this.btnClose);this.Controls.Add(this.lblResDesc);this.Controls.Add(this.lblSuffixInfoDesc);this.Controls.Add(this.txtSuffixInfo);this.Controls.Add(this.lblSuffixSelectDesc);this.Controls.Add(this.lblSaveSelectDesc);this.Controls.Add(this.btnChooseTargetPath);this.Controls.Add(this.btnChooseSourcePath);this.Controls.Add(this.lblTargetDesc);this.Controls.Add(this.lblSourceDesc);this.Controls.Add(this.txtDestinationFolderPath);this.Controls.Add(this.txtSourceFolderPath);this.Controls.Add(this.cboSuffixSelect);this.Controls.Add(this.btnCopy);this.Name frmCopyFiles;this.Text 文件拷贝工具;this.Load new System.EventHandler(this.Form1_Load);this.ResumeLayout(false);this.PerformLayout();}#endregionprivate System.Windows.Forms.Button btnCopy;private System.Windows.Forms.ComboBox cboSuffixSelect;private System.Windows.Forms.TextBox txtSourceFolderPath;private System.Windows.Forms.TextBox txtDestinationFolderPath;private System.Windows.Forms.Label lblSourceDesc;private System.Windows.Forms.Label lblTargetDesc;private System.Windows.Forms.Button btnChooseSourcePath;private System.Windows.Forms.Button btnChooseTargetPath;private System.Windows.Forms.Label lblSaveSelectDesc;private System.Windows.Forms.Label lblSuffixSelectDesc;private System.Windows.Forms.TextBox txtSuffixInfo;private System.Windows.Forms.Label lblSuffixInfoDesc;private System.Windows.Forms.Label lblResDesc;private System.Windows.Forms.Button btnClose;} }
http://www.hkea.cn/news/14267238/

相关文章:

  • 微信购物网站开发一级做爰片a视频网站4
  • 好学校平台网站模板高级搜索指令
  • 南通网站建设案例优化方案英语必修三
  • 网站更换服务器需要重新备案吗手机网站需要多少钱
  • 孝感建设网站郑州网球公开赛
  • 儿童玩具网站模板充电宝seo关键词优化
  • 广西建设厅网站深圳网站建设深正互联
  • 邯郸市网站建设多少钱做网站大概要花多少钱
  • 营销网站建设哪里便宜北京朝阳区
  • 浙江省建设工程检测协会网站个人网站名称举例
  • 怎么做网站布局网站建设中页面模板下载
  • 做一款什么网站赚钱电商怎么做的步骤
  • 东莞凤岗企业网站建设推广网站流量分析网站
  • 天津百度网站快速排名中国五大门户网站
  • 大连网站建设报价关于网站建设的教材
  • 沈阳哪家做网站好做网站水晶头
  • 易讯企业建站系统做网站所需要的公司细责及条款
  • 虚拟网站怎么做的深圳微信网站设计
  • com后缀的网站wordpress威廉希尔插件
  • 悉知网站建设网店推广平台
  • 有哪些做婚品的网站网站开发设计概述
  • 免费建站哪个网站最好网站域名和网址一样吗
  • 邯郸移动网站制作旅游网站建设成都
  • 优化门户网站建设上海国际人力资源开发公司
  • 深圳做网站优化的公司兰亭集势网站模板
  • 网站的推广运营旺道seo优化软件
  • 网站下载服务器配置男人和女人做污的视频网站
  • 站酷网素材苏州北京商场网站建设
  • 个人制作的网站模板seo研究中心培训机构
  • 西安莲湖区建设局网站玉田网站制作