예제 #1
0
        public IFileInfo GetFileInfo(string path)
        {
            var dirPath  = Path.GetDirectoryName(path);
            var fileName = Path.GetFileName(path);
            var dir      = GetDirectoryInfo(dirPath);
            var file     = dir.GetFiles().FirstOrDefault(item => string.Equals(fileName, item.Name, StringComparison.OrdinalIgnoreCase));

            if (file == null)
            {
                if (path.StartsWith("sdata:\\attachments", StringComparison.OrdinalIgnoreCase))
                {
                    var attachment = new Attachment {
                        FileName = fileName
                    };
                    file = new AttachmentFileInfo(_client, _formMode, dir, attachment);
                }
                else
                {
                    var document = new LibraryDocument
                    {
                        FileName  = fileName,
                        Directory = new SDataResource {
                            Key = ((LibraryDirectory)((IResourceHolder)dir).Resource).Key
                        }
                    };
                    file = new LibraryFileInfo(_client, _formMode, dir, document);
                }
            }

            return(file);
        }
예제 #2
0
        public IFileInfo GetFileInfo(string path)
        {
            var dirPath = Path.GetDirectoryName(path);
            var fileName = Path.GetFileName(path);
            var dir = GetDirectoryInfo(dirPath);
            var file = dir.GetFiles().FirstOrDefault(item => string.Equals(fileName, item.Name, StringComparison.OrdinalIgnoreCase));

            if (file == null)
            {
                if (path.StartsWith("sdata:\\attachments", StringComparison.OrdinalIgnoreCase))
                {
                    var attachment = new Attachment {FileName = fileName};
                    file = new AttachmentFileInfo(_client, _formMode, dir, attachment);
                }
                else
                {
                    var document = new LibraryDocument
                        {
                            FileName = fileName,
                            Directory = new SDataResource {Key = ((LibraryDirectory) ((IResourceHolder) dir).Resource).Key}
                        };
                    file = new LibraryFileInfo(_client, _formMode, dir, document);
                }
            }

            return file;
        }