例如,在Svn中,有一个文件test.txt包含“ Welcome”。我想要导出文件中的数据,而不是导出文件,即“ Welcome”。因为我想将其保存在Sql Server中作为byte.Thanks提前。
当svn cat命令输出指定文件或URL的内容(http://www-rohan.sdsu.edu/doc/svn-book-html-chunk/svn.ref.svn.c.cat.html)时, SvnSharp通过SvnClient.Write()(https://sharpsvn.open.collab.net/wiki/SvnToSharpSvn)实现cat命令,您可以使用以下C#代码获取单个文件的内容作为字节数组:
Uri uri = new Uri("https://patn.to.your.svn.com/svn/filename.html");
SvnTarget target = SvnTarget.FromUri(uri);
MemoryStream mst = new MemoryStream();
SvnClient client = new SvnClient();
client.Authentication.ForceCredentials("username", "password");
client.Write(uri, mst);
byte[] content = mst.ToArray();
// to verify it is working, I have printed this to console; you will use above bytes to pass it to SQL or whatever
Console.Out.Write(System.Text.Encoding.Default.GetString(content));
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句