protected override ItemType CreateFileItem(string fullFilePath, bool containsFilePathEntity) { var newFileItem = new SystemCharacteristics.Unix.file_item() { filepath = new EntityItemStringType() { Value = fullFilePath } }; if (!containsFilePathEntity) { var pathParts = fullFilePath.Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); var stringBuilder = new StringBuilder(); for (int i = 0; i < pathParts.Count() - 1; i++) { stringBuilder.Append(pathParts[i] + "/"); } newFileItem.filepath = null; newFileItem.path = base.CreateEntityItemWithValue(stringBuilder.ToString()); newFileItem.filename = this.CreateEntityItemWithValue(pathParts.Last()); } return(newFileItem); }
protected override ItemType CreateFileItem(string fullFilePath, bool containsFilePathEntity) { var newFileItem = new SystemCharacteristics.Unix.file_item() { filepath = new EntityItemStringType() { Value = fullFilePath } }; if (!containsFilePathEntity) { var pathParts = fullFilePath.Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); var stringBuilder = new StringBuilder(); for (int i = 0; i < pathParts.Count() - 1; i++) stringBuilder.Append(pathParts[i] + "/"); newFileItem.filepath = null; newFileItem.path = base.CreateEntityItemWithValue(stringBuilder.ToString()); newFileItem.filename = this.CreateEntityItemWithValue(pathParts.Last()); } return newFileItem; }
private string GetCompleteFilepath(file_item fileItem) { var path = fileItem.path.Value.TrimStart(); var pathSeparator = path.EndsWith("/") ? string.Empty : "/"; var filename = string.Empty; if ((fileItem.filename != null) && (!string.IsNullOrWhiteSpace(fileItem.filename.Value))) filename = fileItem.filename.Value; var completeFilepath = String.Format("{0}{1}{2}", path, pathSeparator, filename); if (!completeFilepath.StartsWith("/")) completeFilepath = "/" + completeFilepath; return completeFilepath; }