本文整理汇总了C#中IBackend.Put方法的典型用法代码示例。如果您正苦于以下问题:C# IBackend.Put方法的具体用法?C# IBackend.Put怎么用?C# IBackend.Put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBackend
的用法示例。
在下文中一共展示了IBackend.Put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Uploadfile
private static void Uploadfile(string localfilename, int i, string remotefilename, IBackend backend, bool disableStreaming)
{
Console.Write("Uploading file {0}, {1} ... ", i, Duplicati.Library.Utility.Utility.FormatSizeString(new System.IO.FileInfo(localfilename).Length));
Exception e = null;
try
{
if (backend is Library.Interface.IStreamingBackend && !disableStreaming)
{
using (System.IO.FileStream fs = new System.IO.FileStream(localfilename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
using (NonSeekableStream nss = new NonSeekableStream(fs))
(backend as Library.Interface.IStreamingBackend).Put(remotefilename, nss);
}
else
backend.Put(remotefilename, localfilename);
e = null;
}
catch (Exception ex)
{
e = ex;
}
if (e != null)
{
Console.WriteLine("Failed to upload file {0}, error message: {1}, remote name: {2}", i, e.ToString(), remotefilename);
while (e.InnerException != null)
{
e = e.InnerException;
Console.WriteLine(string.Format(" Inner exception: {0}", e.ToString()));
}
}
else
{
Console.WriteLine(" done!");
}
}