文件事务问题 - 存储每个文件来自哪里?

发布于 2024-10-02 08:46:36 字数 409 浏览 3 评论 0 原文

我正在创建一个应用程序,它使用 Quartz.NET 根据常规表达式自动下载文件并将文件上传到各种源(HTTP、FTP 和网络路径)。用户可以为每次下载和上传操作选择多个路径,因此一个典型的工作可能是从http服务器下载文件,也可能从ftp服务器下载,并将所有文件上传到网络路径。

目前,我正在从所有下载源下载所有文件,并将它们存储在一个文件夹中(文件夹的名称是特定于该作业的 GUID)。然后在上传阶段,它会简单地读取该目录中的所有文件,并将它们上传到该路径,这很棒。

问题是,对于特定路径,用户可能会在上传完成后请求将其删除,这是一个问题,如何找出文件来自文件夹中的位置?我一直在尝试解决这个问题,例如为每个下载路径创建文件夹,但我需要在下载而不是上传时检查重复的名称,而且我需要合并两个子文件夹......等等!

任何人都可以提供任何想法吗?非常感谢

I am creating an application that uses Quartz.NET to automatically download and upload files to various sources (HTTP, FTP and Network paths) based upon a regular exprsesion. Users can select multiple paths for each download and upload operation, so a typical job may be to download files from a http server, and also download from an ftp server, and upload all files to a network path.

Currently, I am downloading all files from all the download sources, and storing them in a folder (With the name of a folder being a GUID specific to that job). Then for the upload stage, it will simply read all files from that directory, and upload them to the path, which is great.

Problem is, for specific paths, the user may request these to be deleted after upload has completed, which is an issue as how can I find out where a file come from in a folder? I've been trying to think of ways around this, such as creating folders for each download path, but I'd need to check for duplicate names on download rather than upload, plus I'd need to merge both subfolders...etc!

Can anyone offer any ideas? Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

_畞蕅 2024-10-09 08:46:36

以面向对象的方式思考这个问题。
创建一个这样的类

public class File
{

public string source;
public string destination;
public bool deleteSource; //if true delete the source after the copy

}

现在创建一个 File 类的列表,例如 List;文件 并将其保留为应用程序中的变量。
在开始时将对象添加到列表中,然后遍历列表并复制/上传文件。检查 deleteSource 属性,如果为 true,则在复制操作后删除文件。

这是一个基本想法,并根据需要扩展此类。

我想强调的是,以面向对象的方式思考问题并开始设计

Think about this in a object oriented manner.
Create a class like this

public class File
{

public string source;
public string destination;
public bool deleteSource; //if true delete the source after the copy

}

Now create a list of File classes like List<File> files and keep that as variable in your app.
Add objects to the list in the start and then traverse the list and copy / upload files. Check the deleteSource property and if it is true delete the file after the copy operation.

This is a basic idea and expand this class as required.

What I want to stress is that think of a problem in the object oriented way and start designing

铃予 2024-10-09 08:46:36

下载文件时,是否可以创建一个包含源路径和目标路径的单独文本文件?这样您就可以稍后读入该映射并根据源进行必要的处理。

When you download a file, can you create a separate text file that contains the source and destination paths? That way you can read in that mapping later and process them as necessary based on the source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文