根文件夹路径更改时更新子文件夹相对路径(DMS) [英] Update subfolder relative path when root folder path changed (DMS)

查看:134
本文介绍了根文件夹路径更改时更新子文件夹相对路径(DMS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个文档管理系统(ASP.net c#),用户可以在其中创建一个在应用程序本身内创建的文件夹结构,并且文件夹的详细信息(如名称和相对路径)将存储在数据库表中(对于恢复目的)。

我面临的唯一问题是当用户创建许多文件夹和许多子文件夹,然后移动其下有子文件夹的任何文件夹时子文件夹的相对路径在移动的文件夹下不会更改,因为我无法更新它。我需要一个解决方案,如何递归更改移动的根文件夹下的子文件夹的路径。



示例

-root folder1

| -sub folder1

| -sub folder2

| -sub folder2-1

| -sub folder2-2

| -sub folder3

| -sub folder3-1

| -sub folder3-2

| -sub folder3-3

-root folder2

| -sub folder1

| -sub folder2

| -sub folder2-1

| -sub folder2-2



子文件夹2 这是在根文件夹2下移动到子文件夹3-3

我能够更新子文件夹2 的数据库表中的相对路径但是不是它下面的子文件夹的相对路径。



请建议一个解决方案。

解决方案

这个是这样的: Directory.Move Method(String,String)(System.IO) [ ^ ]。



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



-SA

I am developing a Document management system(ASP.net c#) in which users can create a folder structure which gets created within the application itself and details of the folder such as name and relative path get stored in the database table (for recovery purposes).
The only issue that i am facing is that when users create many folders and many sub folders and then move any of the folder which has sub folders under it the relative path of the sub folder under the moved folder doesn't change because i am not able to update it. I need a solution as to how do i recursively change the path of the sub folders under the root folder which get moved.

example
-root folder1
|-sub folder1
|-sub folder2
|-sub folder2-1
|-sub folder2-2
|-sub folder3
|-sub folder3-1
|-sub folder3-2
|-sub folder3-3
-root folder2
|-sub folder1
|-sub folder2
|-sub folder2-1
|-sub folder2-2

Say sub folder2 which is under root folder2 gets moved to sub folder 3-3
I am able to update the relative path in the database table of the sub folder2 but not the relative path of the sub folders under it.

Kindly suggest an solution.

解决方案

This is how: Directory.Move Method (String, String) (System.IO)[^].

See also: How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)[^].

—SA


这篇关于根文件夹路径更改时更新子文件夹相对路径(DMS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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