本文整理汇总了C#中DirectoryInfo.Trim方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.Trim方法的具体用法?C# DirectoryInfo.Trim怎么用?C# DirectoryInfo.Trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryInfo
的用法示例。
在下文中一共展示了DirectoryInfo.Trim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadFile
/// <summary>
/// Logic to Upload file
/// </summary>
/// <param name="input"></param>
private void UploadFile(string input)
{
if (!File.Exists(input) && !Directory.Exists(input))
{
log.Warn("File: " + input + " not exist");
return;
}
IList<Moss> _subFolder = null;
string _FolderToUpload = _directoryRootId;
var attr = File.GetAttributes(input);
if (!attr.HasFlag(SysIO.FileAttributes.Directory))
{
UploadToGoogleDriveV3(input, _directoryRootId);
return;
}
foreach (var dir in _fullList)
{
if (input == dir)
{
_FolderToUpload = null;
_FolderToUpload = CreateFolder(input, _directoryRootId);
numerateFile(_FolderToUpload, input);
break;
}
}
foreach (var dir in Directory.GetDirectories(input))
{
string _directoryName = new DirectoryInfo(input).Name;
_subFolder = findFolder(_directoryName.Trim('\\'), null, null);
if (_subFolder.Count == 0)
break;
string _nameRoot = new DirectoryInfo(_presentRoot).Name.Trim('\\');
List<string> _nameRootSplit = new List<string>(_presentRoot.Split('\\'));
List<string> _inputSplit = new List<string>(input.Split(Path.DirectorySeparatorChar));
_inputSplit.RemoveRange(0, _nameRootSplit.Count);
var _patchWithoutRoot = input.Replace(_presentRoot, "");
_inputSplit.Reverse();
_inputSplit.Add(_nameRoot);
_inputSplit.Add("Backup in Cloud");
try
{
foreach (var _folder in _subFolder)
{
var _remoteFileSplit = makeDirStructure(_folder.Id, true);
if (_inputSplit.Count == _remoteFileSplit.Count && new HashSet<string>(_inputSplit).SetEquals(_remoteFileSplit))
{
_FolderToUpload = null;
_FolderToUpload = CreateFolder(dir, _folder.Id);
numerateFile(_FolderToUpload, dir);
UploadFile(dir);
}
}
}
catch (UnauthorizedAccessException x) { log.Error("Exception[11]: " + x.Message); continue; }
catch (Exception x) { log.Error("Exception[11.1]: " + x.Message); continue; }
}
}