如何根据现有列名更新文件夹中的多个文件名? [英] How to update multiple file name from a folder based on existing column name?

查看:86
本文介绍了如何根据现有列名更新文件夹中的多个文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含五个5列的表,包括没有扩展名的文件名。我想从一个文件夹将filename.pdf更新为gridview中的所有文件



在从grid文件夹更新gridview中的fileNameWithExtension之前我想将文件名与FName列匹配,如果然后将文件名更新为相应的文件名



表是:

 Column1 Column2 Column3 Fname FnameWithExtension 
abv value2 value3 filename
abv value7 value8 filename1









预期结果:





 Column1 Column2 Column3 Fname FnameWithExtension 
abv value2 value3 filename filename.pdf
abv value7 value8 filename1 filename1.pdf













使用此代码绑定gridvew但无法绑定相应的现有文件名



< pre lang =cs> protected void BindGridview()
{
string strpath = @ E:\Internet Tips \;
string [] folders = Directory.GetFiles(strpath, *,SearchOption.AllDirectories);
gvDetails.DataSource = folders;
gvDetails.DataBind();
}

解决方案

看看这里:

如何:复制,删除和移动文件和文件夹(C#编程指南) [ ^ ]

如何:为文件操作提供进度对话框(C#编程指南) [ ^ ]

重命名文件夹c#中的文件 [ ^ ]



试试!


I have a table with five 5 column including file name without extension. I want to update filename.pdf to all files in gridview from a folder

Before updating the fileNameWithExtension in gridview from folder I want to match file name with FName Column, If exist then update file name to corresponding filename

Table is:

Column1   Column2 Column3  Fname     FnameWithExtension
 abv      value2  value3  filename  
 abv      value7  value8  filename1  





Expected result:


Column1 Column2 Column3 Fname     FnameWithExtension
abv      value2  value3 filename  filename.pdf
abv      value7  value8 filename1  filename1.pdf







Using this code to bind the gridvew but not able to bind on corresponding existing File name

protected void BindGridview()
{
string strpath = @"E:\Internet Tips\";
string[] folders = Directory.GetFiles(strpath, "*", SearchOption.AllDirectories);
gvDetails.DataSource = folders;
gvDetails.DataBind();
}

解决方案

Have a look here:
How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)[^]
How to: Provide a Progress Dialog Box for File Operations (C# Programming Guide)[^]
Renaming files in folder c#[^]

Try!


这篇关于如何根据现有列名更新文件夹中的多个文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆