如何重命名文件... [英] How to rename a file...

查看:86
本文介绍了如何重命名文件...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在重命名asp .net中的文件时遇到问题.问题是

=>我正在通过页面上传.pdf格式文件,并通过一些字段文本分配文件名.而且我将该文件存储在项目的文件夹中,并将文件名存储在数据库中.

但是在更新文件时,我不会选择新文件,但是我想更改数据库中旧文件的名称以及特定文件夹中的文件.

因此,我如何更改文件夹中文件的名称?我要更改数据库中的名称,但不能更改文件夹文件名.

谢谢.

Hi to everybody.,

I have a problem with renaming a file in asp .net. The problem is that

=> I am uploading .pdf format file through a page and assigning the file name through some fields text. And i am storing that file in folder of the project and file name in database.

But while updating the file i will not select the new file, but i want to change the name of that old file in database as well as file which is in the particular folder.

so how i can change the name of the file in folder? I''m getting to change the name in database but not in folder file name.

Thanks.

推荐答案

使用

Yes as per the OriginalGriff wrote, if you want to rename the file then, you have to use Move() method which is static method of File class. This class is available in System.IO namespace... <br />
syntax :<br />
<pre>File.Move(oldFileName, newFileName);</pre><br />
or you can use copy and delete command like....<br />
<pre lang="midl">File.Copy(oldFileName, NewFileName);<br />
<br />
File.Delete(oldFileName);</pre><br />
for more details on how to rename file see <a href="http://msdn.microsoft.com/en-us/library/system.io.file(v=vs.71).aspx">this</a>[<a href="http://msdn.microsoft.com/en-us/library/system.io.file(v=vs.71).aspx" target="_blank" title="New Window">^</a>] link...<br />


希望对您有所帮助...

链接 [
I Hope this may Help you...

Link[^]


这篇关于如何重命名文件...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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