开发者

File transactions issue - storing where each file come from?

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜