跳到主要內容

簡單的同步程式

最近有個簡單的檔案同步需求,只增不刪的單向同步,因此寫了一支小程式。

剛好看到Java application frameworks come to .NET,二話不說就用C#寫。

完整程式如下:
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace DirSync
{
class DirSync
{
static void Main(string[] args)
{
if (args.Length < filepathnames =" Directory.GetFileSystemEntries(Src);" destfilepathname =" Dst"> 0)
{
// 若 source時間比較晚則覆寫
FileCopyWithException(pathname, destFilePathName);
}
}
else
{
FileCopyWithException(pathname, destFilePathName);
}
}
}
}

private static void FileCopyWithException(string pathname, string destFilePathName)
{
try
{
File.Copy(pathname, destFilePathName, true);
}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
}
}
}
檔案授權為GPL,你不公開是你家的事,I won't sue you.

留言

這個網誌中的熱門文章

自然人憑證讀卡機驅動程式

鳥毅用的是第一代的自然人憑證讀卡機,EZ100PU(後來有同事買EZmini可以讀SIM卡似乎更好),每年報稅時用一次。 本來只是要申請些政府業務,一時之間找不到光碟,沒想到在 驅動程式下載 居然看到Linux和Mac的驅動程式,剩下的就是政府單位的網頁和程式應該改版了吧!!!

Personal Bookmark

Java SE 6 + Firefox 2 UI 問題 As I do . Google拋棄了了SOAP API,浮想聯翩 https://www.gandi.net/ VS 2005 SP1中文版推出 Windows Vista中文版下載 ASP.NET 2.0網頁執行管線與快取原理 Cache 2.0快取架構與快取資料自動移除架構圖 flickr sync 分享與試用 SUN Looking Glass 3D圖形介面發布1.0 雅虎勵精圖治推動改革 Wait and see 國內某SOC疑遭駭客入侵 大砲開講 Very Important! 微軟公佈Vista安全程式介面草案 一窺Google開原碼庫房乾坤 qing is writing a dig girl net... wait and see

完美簡繁轉換

因為之前一直用ConvertZ轉影片字幕檔,但是我在家用Mac居多, 加上聽完HITCON 2011後在公司也不太想用Windows了(大誤) ,而且ConvertZ必須自己指定檔案的編碼,對於多檔轉換時很麻煩(找的字幕檔編碼不一定是某種編碼),希望能有更方便的解決方案。原本想要用 開放中文轉換 , opencc ,但是在Windows編譯上遇到困難,後來又看到 convert2utf8 ,本以為它會自動轉換編碼,用了才發現不會,再找了 Universal Encoding Detector ,自己加上自動編碼偵測,並在轉換檔加上 BOM 。