我正在创建一个应用程序,它使用 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
发布评论
评论(2)
以面向对象的方式思考这个问题。
创建一个这样的类
现在创建一个 File 类的列表,例如
List;文件
并将其保留为应用程序中的变量。在开始时将对象添加到列表中,然后遍历列表并复制/上传文件。检查 deleteSource 属性,如果为 true,则在复制操作后删除文件。
这是一个基本想法,并根据需要扩展此类。
我想强调的是,以面向对象的方式思考问题并开始设计
Think about this in a object oriented manner.
Create a class like this
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
下载文件时,是否可以创建一个包含源路径和目标路径的单独文本文件?这样您就可以稍后读入该映射并根据源进行必要的处理。
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.