Search code examples
c#.netsvnsharpsvn

Get creation date for the file with SharpSvn


I'm playing with SharpSvn and have to analyze folder in repository
and I need to know when some file has be created there,
not last modification date, but when it was created,

Do you have any idea how to do that?

I started with the following:

    Collection<SvnLogEventArgs> logitems;
    var c = client.GetLog(new Uri(server_path), out logitems);


    foreach (var i in logitems)
    {
        var properties = i.CustomProperties;
        foreach (var p in properties)
        {
             Console.WriteLine(p.ToString());
             Console.WriteLine(p.Key);
             Console.WriteLine(p.StringValue);
        }
    }

But I don't see any creation date there.
Does someone know where to get it?


Solution

  • Looks like I can't do that. Here is how I solved this problem: I'm getting the time if it was the SvnChangeAction.Add. Here is the code (SvnFile is my own class, not from SharpSvn):

    public static List<SvnFile> GetSvnFiles(this SvnClient client, string uri_path)
    {
        // get logitems
        Collection<SvnLogEventArgs> logitems;
        client.GetLog(new Uri(uri_path), out logitems);
    
        var result = new List<SvnFile>();
    
        // get craation date for each
        foreach (var logitem in logitems.OrderBy(logitem => logitem.Time))
        {
            foreach (var changed_path in logitem.ChangedPaths)
            {
                string filename = Path.GetFileName(changed_path.Path);
                if (changed_path.Action == SvnChangeAction.Add)
                {
                    result.Add(new SvnFile() { Name = filename, Created = logitem.Time });
                }
            }
        }
    
        return result;
    }