求文件下载的解决方案
功能要求:
1:对上传的文件进行定时转移(3个月前的数据转移到另一台服务器)
2:对上传文件的下载,判断是否是3个月前的文件,如果是,从另一台服务器下载,如果不是从当前服务器下载
现在难点是:不知道如果从另一台服务器下载文件
------解决方案--------------------友情帮顶
------解决方案--------------------文件创建日期可以用来做依据,
设一个共享路径,比如服务器A上的共享路径,也可以不同于原上传路径,
从服务器B直接读取该共享路径下的所有文件的创建日期或修改日期,再依条件移动到服务器B上
------解决方案--------------------FileSystemWatcher 好像有这个类吧&
我自己写的小程序 可以参考一下[如果文件有更改或传到目前文件夹下]
class Program
{
private static string targetDir;
public static void Main()
{
string[] args = System.Environment.GetCommandLineArgs();
// If a directory is not specified, exit program.
if (args.Length != 4)
{
// Display the proper way to call the program.
Console.WriteLine( "用法:FileWatcher.exe WatchDir FilterType TargetDir ");
Console.WriteLine(@ "eg:FileWatcher.exe d:\relisten *.wma \\fugle-server\segment\ ");
return;
}
Console.WriteLine( "监视文件夹: " + args[1]);
Console.WriteLine( "监视文件类型: " + args[2]);
Console.WriteLine( "复制到文件夹: " + args[3]);
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = args[1];
// Only watch text files.
watcher.Filter = args[2];
//target File
targetDir = args[3];
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.CreationTime;
// Add event handlers.
watcher.Created += new FileSystemEventHandler(watcher_Created);
watcher.Changed += new FileSystemEventHandler(watcher_Changed);
// Begin watching.
watcher.EnableRaisingEvents = true;
// Wait for the user to quit the program.
Console.WriteLine( "Press \ 'q\ ' to quit the sample. ");
while (Console.Read() != 'q ') ;
}
static void watcher_Changed(object sender, FileSystemEventArgs e)
{
//throw new Exception( "The method or operation is not implemented. ");
Console.WriteLine( "File: " + e.FullPath + " " + e.ChangeType);
Console.WriteLine( "Coping To " + targetDir + e.Name);
if (File.Exists(targetDir + e.Name))
{
File.Delete(targetDir + e.Name);
}
File.Copy(e.FullPath, targetDir + e.Name);
}
static void watcher_Created(object sender, FileSystemEventArgs e)
{
//throw new Exception( "The method or operation is not implemented. ");
Console.WriteLine( "File: " + e.FullPath + " " + e.ChangeType);
Console.WriteLine( "Coping To " + targetDir + e.Name);
File.Copy(e.FullPath, targetDir + e.Name);
}
}
------解决方案--------------------http://www.cnblogs.com/webman/archive/2006/11/15/561372.html