Search code examples
c#.netsvnc#-3.0

How to programatically do file versioning with SVN and .NET?


We have a report generator. Daily, it writes its data into a Excel file.

For reasons of version controlling and file data safety, we need to alter this file, and commit the changes into a repository.

Do you recommend any .net SVN API you've used?


Solution

  • You should take a look at the SharpSvn .NET library. You will probably need checkout and commit commands:

    Checking out:

    string wcPath = "c:\\my working copy";
    using (SvnClient client = new SvnClient())
    {
        client.CheckOut(new Uri("http://server/path/to/repos"), wcPath);
    }
    

    Committing:

    string wcPath = "c:\\my working copy";
    SvnCommitArgs a = new SvnCommitArgs();
    a.LogMessage = "My log message";
    
    using (SvnClient client = new SvnClient())
    {
        client.Commit(wcPath, a);
    }