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

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

眼泪淡了忧伤 发布于 2021-12-01 字数 269 浏览 810 回复 4 原文

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?

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。



需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。


熟人话多 2022-06-07 4 楼

The simplest would be to spawn a process and call SVN.exe
to commit your changes.

Here is a similiar question that was asked.

Does anyone know of a good C# API for Subversion?

Here is another resource

SVN Libraries for .NET?

爱的那么颓废 2022-06-07 3 楼

We are using tool that actually searching for installed TortoiseSVN in predefined locations and using it command-line api. If that is for Windows and it's for not redistribution - it might be easier to do.

Helpful code for cmd:

@echo off
if exist "%ProgramW6432%TortoiseSVNbinTortoiseProc.exe" set patht=%ProgramW6432%
if exist "%ProgramFiles%TortoiseSVNbinTortoiseProc.exe" set patht=%ProgramFiles%
if exist "%ProgramFiles(x86)%TortoiseSVNbinTortoiseProc.exe" set patht=%ProgramFiles(x86)%

echo Placing SVN Commit
"%patht%TortoiseSVNbinTortoiseProc.exe" /command:commit /path:"%CD%" /notempfile    

If you still want to do that task from code - SharpSVN is better choiсe

烈酒灼喉 2022-06-07 2 楼

You might be able to turn on Autoversioning for your repository. Since it uses WebDAV, you can treat the repository just like a network drive (Web Folder). And you can treat the file as a normal file, just open, modify, and save.

If it were me , I would create a new repository for the excel data files. I don't think I'd like my code being autoversioned :)

稚气少女 2022-06-07 1 楼

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);


string wcPath = "c:\my working copy";
SvnCommitArgs a = new SvnCommitArgs();
a.LogMessage = "My log message";

using (SvnClient client = new SvnClient())
    client.Commit(wcPath, a);