public override LogItem GetLogItem(string baseAddress, string path)
        {
            if (String.IsNullOrWhiteSpace(path))
            {
                path = ".";
            }
            path = path.TrimStart('/');

            string windowsPath = Path.GetFullPath(Path.Combine(RootPath, path.Replace('/', '\\')));

            if (_fileSystem.Directory.Exists(windowsPath))
            {
                var logItems     = new List <LogItem>();
                var logDirectory = new LogItems()
                {
                    Name  = Path.GetFileName(windowsPath),
                    Path  = windowsPath,
                    Url   = baseAddress,
                    Root  = Name,
                    Items = logItems
                };

                var directory = _fileSystem.DirectoryInfo.FromDirectoryName(windowsPath);
                var files     = directory.GetFileSystemInfos();
                foreach (var file in files)
                {
                    var logItem = new LogItem()
                    {
                        Path        = Path.Combine(windowsPath, file.Name),
                        IsDirectory = file.Attributes.HasFlag(System.IO.FileAttributes.Directory),
                        Name        = file.Name,
                        Date        = file.LastWriteTimeUtc,
                        Url         = baseAddress + "/" + file.Name,
                        DownloadUrl = baseAddress + "/" + file.Name + "&download=true"
                    };

                    var fileInfoBase = file as FileInfoBase;
                    if (fileInfoBase != null)
                    {
                        logItem.Size = fileInfoBase.Length;
                    }

                    logItems.Add(logItem);
                }

                var parentLogItem = new LogItem()
                {
                    IsDirectory = true,
                    Date        = DateTime.MaxValue,
                    Name        = "..",
                    Url         = baseAddress.Substring(0, baseAddress.LastIndexOf('/'))
                };

                logItems.Add(parentLogItem);

                return(logDirectory);
            }

            var fileInfo = _fileSystem.FileInfo.FromFileName(windowsPath);

            if (fileInfo.Exists)
            {
                return(new LogItem()
                {
                    Path = windowsPath,
                    IsDirectory = false,
                    Name = Path.GetFileName(windowsPath),
                    Size = fileInfo.Length,
                    Date = fileInfo.LastWriteTimeUtc,
                    Url = baseAddress,
                    DownloadUrl = baseAddress + "&download=true"
                });
            }

            return(null);
        }
        public override LogItem GetLogItem(string baseAddress, string path)
        {
            if (String.IsNullOrWhiteSpace(path))
            {
                path = ".";
            }
            path = path.TrimStart('/');

            string windowsPath = Path.GetFullPath(Path.Combine(RootPath, path.Replace('/', '\\')));

            if (_fileSystem.Directory.Exists(windowsPath))
            {
                var logItems = new List<LogItem>();
                var logDirectory = new LogItems()
                {
                    Name = Path.GetFileName(windowsPath),
                    Path = windowsPath,
                    Url = baseAddress,
                    Root = Name,
                    Items = logItems
                };

                var directory = _fileSystem.DirectoryInfo.FromDirectoryName(windowsPath);
                var files = directory.GetFileSystemInfos();
                foreach (var file in files)
                {
                    var logItem = new LogItem()
                    {
                        Path = Path.Combine(windowsPath, file.Name),
                        IsDirectory = file.Attributes.HasFlag(System.IO.FileAttributes.Directory),
                        Name = file.Name,
                        Date = file.LastWriteTimeUtc,
                        Url = baseAddress + "/" + file.Name,
                        DownloadUrl = baseAddress + "/" + file.Name + "&download=true"
                    };

                    var fileInfoBase = file as FileInfoBase;
                    if (fileInfoBase != null)
                    {
                        logItem.Size = fileInfoBase.Length;
                    }

                    logItems.Add(logItem);
                }

                return logDirectory;
            }

            var fileInfo = _fileSystem.FileInfo.FromFileName(windowsPath);
            if (fileInfo.Exists)
            {
                return new LogItem()
                {
                    Path = windowsPath,
                    IsDirectory = false,
                    Name = Path.GetFileName(windowsPath),
                    Size = fileInfo.Length,
                    Date = fileInfo.LastWriteTimeUtc,
                    Url = baseAddress,
                    DownloadUrl = baseAddress + "&download=true"
                };
            }

            return null;
        }
        public override LogItem GetLogItem(string baseAddress, string path)
        {
            if (_sasUrl == null)
            {
                return(null);
            }

            if (String.IsNullOrWhiteSpace(path))
            {
                path = String.Empty;
            }

            path        = path.TrimStart('/');
            baseAddress = baseAddress.TrimEnd('/');

            var blobContainer = new CloudBlobContainer(new Uri(_sasUrl));

            var name = Path.GetFileName(path.TrimEnd('/').Replace("/", "\\"));

            if (path.EndsWith("/") || path == String.Empty)
            {
                var logItems     = new List <LogItem>();
                var logDirectory = new LogItems()
                {
                    Url         = baseAddress,
                    Name        = name,
                    IsDirectory = true,
                    Path        = path,
                    Root        = Name,
                    Items       = logItems
                };

                var blobs = blobContainer.ListBlobs(String.IsNullOrEmpty(path) ? null : path);
                foreach (var blob in blobs)
                {
                    if (blob is CloudBlockBlob)
                    {
                        var cloudBlockBlob = blob as CloudBlockBlob;
                        var innerName      = Path.GetFileName(cloudBlockBlob.Name.TrimEnd('/').Replace("/", "\\"));
                        logItems.Add(new LogItem()
                        {
                            Name        = innerName,
                            Size        = cloudBlockBlob.Properties.Length,
                            Path        = path + innerName,
                            Date        = cloudBlockBlob.Properties.LastModified.HasValue ? (DateTime?)cloudBlockBlob.Properties.LastModified.Value.DateTime : null,
                            Url         = baseAddress + "/" + innerName,
                            DownloadUrl = baseAddress + "/" + innerName + "&download=true"
                        });
                    }
                    else if (blob is CloudBlobDirectory)
                    {
                        var innerCloudBlobDirectory = blob as CloudBlobDirectory;
                        var innerPath = innerCloudBlobDirectory.Prefix;
                        var innerName = Path.GetFileName(innerPath.TrimEnd('/').Replace("/", "\\"));
                        logItems.Add(new LogItem()
                        {
                            IsDirectory = true,
                            Name        = innerName,
                            Path        = innerPath,
                            Url         = baseAddress + "/" + innerName + "/"
                        });
                    }
                }

                var parentLogItem = new LogItem()
                {
                    IsDirectory = true,
                    Date        = DateTime.MaxValue,
                    Name        = "..",
                    Url         = baseAddress.Substring(0, baseAddress.LastIndexOf('/')) + "/"
                };

                logItems.Add(parentLogItem);

                return(logDirectory);
            }

            var blockBlobReference = blobContainer.GetBlockBlobReference(path);

            if (blockBlobReference.Exists())
            {
                return(new LogItem()
                {
                    Name = name,
                    Size = blockBlobReference.Properties.Length,
                    Path = path,
                    Date = blockBlobReference.Properties.LastModified.HasValue ? (DateTime?)blockBlobReference.Properties.LastModified.Value.DateTime : null,
                    Url = baseAddress,
                    DownloadUrl = blockBlobReference.Uri + _sas
                });
            }

            return(null);
        }