• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Core.File类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ASC.Files.Core.File的典型用法代码示例。如果您正苦于以下问题:C# File类的具体用法?C# File怎么用?C# File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



File类属于ASC.Files.Core命名空间,在下文中一共展示了File类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FileWrapper

        /// <summary>
        /// </summary>
        /// <param name="file"></param>
        public FileWrapper(File file)
            : base(file)
        {
            FolderId = file.FolderID;
            if (file.RootFolderType == FolderType.USER
                && !Equals(file.RootFolderCreator, SecurityContext.CurrentAccount.ID))
            {
                RootFolderType = FolderType.SHARE;
                using (var folderDao = Global.DaoFactory.GetFolderDao())
                {
                    var parentFolder = folderDao.GetFolder(file.FolderID);
                    if (!Global.GetFilesSecurity().CanRead(parentFolder))
                        FolderId = Global.FolderShare;
                }
            }

            Version = file.Version;
            ContentLength = file.ContentLengthString;
            FileStatus = file.FileStatus;
            PureContentLength = file.ContentLength;
            try
            {
                ViewUrl = file.ViewUrl;

                WebUrl = CommonLinkUtility.GetFileWebPreviewUrl(file.Title, file.ID);
            }
            catch (Exception)
            {
                //Don't catch anything here because of httpcontext
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:34,代码来源:FileWrapper.cs


示例2: SaveFile

 public File SaveFile(File file, Stream stream)
 {
     using (var dao = FilesIntegration.GetFileDao())
     {
         return dao.SaveFile(file, stream);
     }
 }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:7,代码来源:FileEngine.cs


示例3: GetLink

        public static string GetLink(File file)
        {
            var url = file.ViewUrl;

            if (!FileUtility.CanImageView(file.Title) && TenantExtra.GetTenantQuota().DocsEdition)
                url = FilesLinkUtility.GetFileWebPreviewUrl(file.Title, file.ID);

            var linkParams = CreateKey(file.ID.ToString());
            url += "&" + FilesLinkUtility.DocShareKey + "=" + HttpUtility.UrlEncode(linkParams);

            return CommonLinkUtility.GetFullAbsolutePath(url);
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:12,代码来源:FileShareLink.cs


示例4: Check

        public static FileShare Check(string key, IFileDao fileDao, out File file)
        {
            file = null;
            if (string.IsNullOrEmpty(key)) return FileShare.Restrict;
            var fileId = Parse(key);
            file = fileDao.GetFile(fileId);
            if (file == null) return FileShare.Restrict;

            var filesSecurity = Global.GetFilesSecurity();
            if (filesSecurity.CanEdit(file, FileConstant.ShareLinkId)) return FileShare.ReadWrite;
            if (filesSecurity.CanRead(file, FileConstant.ShareLinkId)) return FileShare.Read;
            return FileShare.Restrict;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:13,代码来源:FileShareLink.cs


示例5: GetFileStream

        public Stream GetFileStream(File file, long offset)
        {
            var fileToDownload = ProviderInfo.GetFileById(file.ID);
            if (fileToDownload == null)
                throw new ArgumentNullException("file", Web.Files.Resources.FilesCommonResource.ErrorMassage_FileNotFound);

            var fileStream = ProviderInfo.GetFileStream(fileToDownload.ServerRelativeUrl);

            if (offset > 0)
                fileStream.Seek(offset, SeekOrigin.Begin);

            return fileStream;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:13,代码来源:SharePointFileDao.cs


示例6: GetLink

        public static string GetLink(File file)
        {
            var url = file.ViewUrl;

            if (FileUtility.CanWebView(file.Title)
                && TenantExtra.GetTenantQuota().DocsEdition)
                url = CommonLinkUtility.GetFileWebEditorUrl(file.ID);

            var linkParams = Signature.Create(file.ID.ToString(), Global.GetDocDbKey());
            url += "&" + CommonLinkUtility.DocShareKey + "=" + HttpUtility.UrlEncode(linkParams);

            return CommonLinkUtility.GetFullAbsolutePath(url);
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:13,代码来源:FileShareLink.cs


示例7: ProcessUpload

        public override FileUploadResult ProcessUpload(HttpContext context)
        {
            var fileUploadResult = new FileUploadResult();

            if (!ProgressFileUploader.HasFilesToUpload(context)) return fileUploadResult;

            var file = new ProgressFileUploader.FileToUpload(context);

            if (String.IsNullOrEmpty(file.FileName) || file.ContentLength == 0)
                throw new InvalidOperationException("Invalid file.");

            if (0 < SetupInfo.MaxUploadSize && SetupInfo.MaxUploadSize < file.ContentLength)
                throw FileSizeComment.FileSizeException;

            if (CallContext.GetData("CURRENT_ACCOUNT") == null)
                CallContext.SetData("CURRENT_ACCOUNT", new Guid(context.Request["UserID"]));


            var fileName = file.FileName.LastIndexOf('\\') != -1
                               ? file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1)
                               : file.FileName;


            var document = new File
                               {
                                   Title = fileName,
                                   FolderID = Global.DaoFactory.GetFileDao().GetRoot(),
                                   ContentLength = file.ContentLength
                               };

            document.ContentType = MimeMapping.GetMimeMapping(document.Title);

            document = Global.DaoFactory.GetFileDao().SaveFile(document, file.InputStream);

            fileUploadResult.Data = document.ID;
            fileUploadResult.FileName = document.Title;
            fileUploadResult.FileURL = document.FileUri;


            fileUploadResult.Success = true;


            return fileUploadResult;

        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:45,代码来源:FileUploaderHandler.cs


示例8: GetFileStream

        public Stream GetFileStream(File file, long offset)
        {
            var driveId = MakeDriveId(file.ID);
            CacheReset(driveId, true);
            var driveFile = GetDriveEntry(file.ID);
            if (driveFile == null) throw new ArgumentNullException("file", Web.Files.Resources.FilesCommonResource.ErrorMassage_FileNotFound);
            if (driveFile is ErrorDriveEntry) throw new Exception(((ErrorDriveEntry)driveFile).Error);

            var fileStream = GoogleDriveProviderInfo.Storage.DownloadStream(driveFile);

            if (fileStream.CanSeek)
                file.ContentLength = fileStream.Length; // hack for google drive

            if (fileStream.CanSeek && offset > 0)
                fileStream.Seek(offset, SeekOrigin.Begin);

            return fileStream;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:18,代码来源:GoogleDriveFileDao.cs


示例9: SendLinkToEmail

        public static void SendLinkToEmail(File file, String url, String message, List<String> addressRecipients)
        {
            if (file == null || String.IsNullOrEmpty(url))
                throw new ArgumentException();

            var recipients = addressRecipients
                .ConvertAll(address => (IRecipient) (new DirectRecipient(Guid.NewGuid().ToString(), String.Empty, new[] {address}, false)));

            Instance.SendNoticeToAsync(
                NotifyConstants.Event_LinkToEmail,
                null,
                recipients.ToArray(),
                false,
                new TagValue(NotifyConstants.Tag_DocumentTitle, file.Title),
                new TagValue(NotifyConstants.Tag_DocumentUrl, CommonLinkUtility.GetFullAbsolutePath(url)),
                new TagValue(NotifyConstants.Tag_AccessRights, GetAccessString(file.Access)),
                new TagValue(NotifyConstants.Tag_Message, message.HtmlEncode())
                );
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:19,代码来源:NotifyClient.cs


示例10: SendLinkToEmail

        public static void SendLinkToEmail(File file, String url, String message, List<String> addressRecipients)
        {
            if (file == null || String.IsNullOrEmpty(url))
                throw new ArgumentException();

            var recipients = addressRecipients
                .ConvertAll(address => (IRecipient)(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), String.Empty, new[] { address }, false)));

            Instance.SendNoticeToAsync(
                NotifyConstants.Event_LinkToEmail,
                null,
                recipients.ToArray(),
                new[] { "email.sender" },
                null,
                new TagValue(NotifyConstants.Tag_DocumentTitle, file.Title),
                new TagValue(NotifyConstants.Tag_DocumentUrl, CommonLinkUtility.GetFullAbsolutePath(url)),
                new TagValue(NotifyConstants.Tag_AccessRights, GetAccessString(file.Access, CultureInfo.CurrentUICulture)),
                new TagValue(NotifyConstants.Tag_Message, message.HtmlEncode()),
                new TagValue(NotifyConstants.Tag_UserEmail, CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).Email)
                );
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:21,代码来源:NotifyClient.cs


示例11: ExecPathFromFile

        private ItemNameValueCollection ExecPathFromFile(File file, string path)
        {
            FileMarker.RemoveMarkAsNew(file);

            var title = file.Title;

            if (_files.ContainsKey(file.ID.ToString()))
            {
                var convertToExt = string.Empty;
                if (_quotaDocsEdition || FileUtility.InternalExtension.Values.Contains(convertToExt))
                    convertToExt = _files[file.ID.ToString()];

                if (!string.IsNullOrEmpty(convertToExt))
                {
                    title = FileUtility.ReplaceFileExtension(title, convertToExt);
                }
            }

            var entriesPathId = new ItemNameValueCollection();
            entriesPathId.Add(path + title, file.ID.ToString());

            return entriesPathId;
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:23,代码来源:FileDownloadOperation.cs


示例12: GetFileStream

        public Stream GetFileStream(File file, long offset)
        {
            //NOTE: id here is not converted!
            var fileToDownload = GetFileById(file.ID);
            //Check length of the file
            if (fileToDownload == null)
                throw new ArgumentNullException("file", Web.Files.Resources.FilesCommonResource.ErrorMassage_FileNotFound);

            //if (fileToDownload.Length > SetupInfo.AvailableFileSize)
            //{
            //    throw FileSizeComment.FileSizeException;
            //}

            var fileStream = fileToDownload.GetDataTransferAccessor().GetDownloadStream();

            if (fileStream.CanSeek)
                file.ContentLength = fileStream.Length; // hack for google drive

            if (offset > 0)
                fileStream.Seek(offset, SeekOrigin.Begin);

            return fileStream;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:23,代码来源:SharpBoxFileDao.cs


示例13: SendLinkToEmail

        public static void SendLinkToEmail(File file, String url, String message, List<String> addressRecipients)
        {
            if (file == null || String.IsNullOrEmpty(url))
                throw new ArgumentException();

            foreach (var recipients in addressRecipients
                .Select(addressRecipient => (IRecipient) (new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), String.Empty, new[] {addressRecipient}, false))))
            {
                Instance.SendNoticeToAsync(
                    NotifyConstants.Event_LinkToEmail,
                    null,
                    new[] {recipients},
                    new[] {"email.sender"},
                    null,
                    new TagValue(NotifyConstants.Tag_DocumentTitle, file.Title),
                    new TagValue(NotifyConstants.Tag_DocumentUrl, CommonLinkUtility.GetFullAbsolutePath(url)),
                    new TagValue(NotifyConstants.Tag_AccessRights, GetAccessString(file.Access, CultureInfo.CurrentUICulture)),
                    new TagValue(NotifyConstants.Tag_Message, message.HtmlEncode()),
                    new TagValue(NotifyConstants.Tag_UserEmail, CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).Email),
                    new TagValue(CommonTags.WithPhoto, CoreContext.Configuration.Personal ? "personal" : ""),
                    new TagValue(CommonTags.IsPromoLetter, CoreContext.Configuration.Personal ? "true" : "false")
                    );
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:24,代码来源:NotifyClient.cs


示例14: ToFeed

        private Feed ToFeed(File file)
        {
            var rootFolder = new FolderDao(Tenant, DbId).GetFolder(file.FolderID);

            if (file.SharedToMeOn.HasValue)
            {
                var feed = new Feed(new Guid(file.SharedToMeBy), file.SharedToMeOn.Value, true)
                    {
                        Item = sharedFileItem,
                        ItemId = string.Format("{0}_{1}", file.ID, file.CreateByString),
                        ItemUrl = CommonLinkUtility.GetFileRedirectPreviewUrl(file.ID, true),
                        Product = Product,
                        Module = Name,
                        Title = file.Title,
                        AdditionalInfo = file.ContentLengthString,
                        AdditionalInfo2 = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                        AdditionalInfo3 = rootFolder.FolderType == FolderType.DEFAULT ? CommonLinkUtility.GetFileRedirectPreviewUrl(file.FolderID, false) : string.Empty,
                        Keywords = string.Format("{0}", file.Title),
                        HasPreview = false,
                        CanComment = false,
                        Target = file.CreateByString,
                        GroupId = GetGroupId(sharedFileItem, new Guid(file.SharedToMeBy), file.FolderID.ToString())
                    };

                return feed;
            }

            var updated = file.Version != 1;
            return new Feed(file.ModifiedBy, file.ModifiedOn)
                {
                    Item = fileItem,
                    ItemId = string.Format("{0}_{1}", file.ID, file.Version > 1 ? 1 : 0),
                    ItemUrl = CommonLinkUtility.GetFileRedirectPreviewUrl(file.ID, true),
                    Product = Product,
                    Module = Name,
                    Action = updated ? FeedAction.Updated : FeedAction.Created,
                    Title = file.Title,
                    AdditionalInfo = file.ContentLengthString,
                    AdditionalInfo2 = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                    AdditionalInfo3 = rootFolder.FolderType == FolderType.DEFAULT ? CommonLinkUtility.GetFileRedirectPreviewUrl(file.FolderID, false) : string.Empty,
                    Keywords = string.Format("{0}", file.Title),
                    HasPreview = false,
                    CanComment = false,
                    Target = null,
                    GroupId = GetGroupId(fileItem, file.ModifiedBy, file.FolderID.ToString(), updated ? 1 : 0)
                };
        }
开发者ID:vlslavik,项目名称:teamlab.v7.5,代码行数:47,代码来源:FilesModule.cs


示例15: CanEdit

        public static bool CanEdit(File file)
        {
            if (!(IsAdmin || file.CreateBy == SecurityContext.CurrentAccount.ID || file.ModifiedBy == SecurityContext.CurrentAccount.ID))
                return false;

            if ((file.FileStatus & FileStatus.IsEditing) == FileStatus.IsEditing)
                return false;

            return true;
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:10,代码来源:CRMSecutiry.cs


示例16: ToResponseObject

 private static object ToResponseObject(File file)
 {
     return new
         {
             id = file.ID,
             folderId = file.FolderID,
             version = file.Version,
             title = file.Title,
             provider_key = file.ProviderKey
         };
 }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:11,代码来源:ChunkedUploaderHandler.cs


示例17: PageLoad

        private void PageLoad()
        {
            var editPossible = !RequestEmbedded;
            var isExtenral = false;

            File file;
            var fileUri = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(RequestFileUrl))
                {
                    _fileNew = (Request["new"] ?? "") == "true";

                    var app = ThirdPartySelector.GetAppByFileId(RequestFileId);
                    if (app == null)
                    {
                        var ver = string.IsNullOrEmpty(Request[FilesLinkUtility.Version]) ? -1 : Convert.ToInt32(Request[FilesLinkUtility.Version]);

                        file = DocumentServiceHelper.GetParams(RequestFileId, ver, RequestShareLinkKey, _fileNew, editPossible, !RequestView, out _docParams);

                        _fileNew = _fileNew && file.Version == 1 && file.ConvertedType != null && file.CreateOn == file.ModifiedOn;
                    }
                    else
                    {
                        isExtenral = true;

                        bool editable;
                        _thirdPartyApp = true;
                        file = app.GetFile(RequestFileId, out editable);
                        file = DocumentServiceHelper.GetParams(file, true, true, true, editable, editable, editable, out _docParams);

                        _docParams.FileUri = app.GetFileStreamUrl(file);
                        _docParams.FolderUrl = string.Empty;
                    }
                }
                else
                {
                    isExtenral = true;

                    fileUri = RequestFileUrl;
                    var fileTitle = Request[FilesLinkUtility.FileTitle];
                    if (string.IsNullOrEmpty(fileTitle))
                        fileTitle = Path.GetFileName(HttpUtility.UrlDecode(fileUri)) ?? "";

                    if (CoreContext.Configuration.Standalone)
                    {
                        try
                        {
                            var webRequest = WebRequest.Create(RequestFileUrl);
                            using (var response = webRequest.GetResponse())
                            using (var responseStream = new ResponseStream(response))
                            {
                                var externalFileKey = DocumentServiceConnector.GenerateRevisionId(RequestFileUrl);
                                fileUri = DocumentServiceConnector.GetExternalUri(responseStream, MimeMapping.GetMimeMapping(fileTitle), externalFileKey);
                            }
                        }
                        catch (Exception error)
                        {
                            Global.Logger.Error("Cannot receive external url for \"" + RequestFileUrl + "\"", error);
                        }
                    }

                    file = new File
                        {
                            ID = RequestFileUrl,
                            Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                        };

                    file = DocumentServiceHelper.GetParams(file, true, true, true, false, false, false, out _docParams);
                    _docParams.CanEdit = editPossible && !CoreContext.Configuration.Standalone;
                    _editByUrl = true;

                    _docParams.FileUri = fileUri;
                }
            }
            catch (Exception ex)
            {
                _errorMessage = ex.Message;
                return;
            }

            if (_docParams.ModeWrite && FileConverter.MustConvert(file))
            {
                try
                {
                    file = FileConverter.ExecDuplicate(file, RequestShareLinkKey);
                }
                catch (Exception e)
                {
                    _docParams = null;
                    _errorMessage = e.Message;
                    return;
                }

                var comment = "#message/" + HttpUtility.UrlEncode(FilesCommonResource.CopyForEdit);

                Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                return;
            }
//.........这里部分代码省略.........
开发者ID:vipwan,项目名称:CommunityServer,代码行数:101,代码来源:DocEditor.aspx.cs


示例18: GetFile

        public File GetFile(string fileId, out bool editable)
        {
            Global.Logger.Debug("GoogleDriveApp: get file " + fileId);
            fileId = ThirdPartySelector.GetFileId(fileId);

            var token = Token.GetToken(AppAttr);
            var driveFile = GetDriveFile(fileId, token);
            editable = false;

            if (driveFile == null) return null;

            var jsonFile = JObject.Parse(driveFile);

            var file = new File
                {
                    ID = ThirdPartySelector.BuildAppFileId(AppAttr, jsonFile.Value<string>("id")),
                    Title = Global.ReplaceInvalidCharsAndTruncate(GetCorrectTitle(jsonFile)),
                    CreateOn = TenantUtil.DateTimeFromUtc(jsonFile.Value<DateTime>("createdDate")),
                    ModifiedOn = TenantUtil.DateTimeFromUtc(jsonFile.Value<DateTime>("modifiedDate")),
                    ContentLength = Convert.ToInt64(jsonFile.Value<string>("fileSize")),
                    ModifiedByString = jsonFile.Value<string>("lastModifyingUserName"),
                    ProviderKey = "Google"
                };

            var owners = jsonFile.Value<JArray>("ownerNames");
            if (owners != null)
            {
                file.CreateByString = owners.ToObject<List<string>>().FirstOrDefault();
            }

            editable = jsonFile.Value<bool>("editable");
            return file;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:33,代码来源:GoogleDriveApp.cs


示例19: GetFileStreamUrl

        public string GetFileStreamUrl(File file)
        {
            if (file == null) return string.Empty;

            var fileId = ThirdPartySelector.GetFileId(file.ID.ToString());

            Global.Logger.Debug("GoogleDriveApp: get file stream url " + fileId);

            var uriBuilder = new UriBuilder(CommonLinkUtility.GetFullAbsolutePath(ThirdPartyAppHandler.HandlerPath));
            if (uriBuilder.Uri.IsLoopback)
            {
                uriBuilder.Host = Dns.GetHostName();
            }
            var query = uriBuilder.Query;
            query += FilesLinkUtility.Action + "=stream&";
            query += FilesLinkUtility.FileId + "=" + HttpUtility.UrlEncode(fileId) + "&";
            query += CommonLinkUtility.ParamName_UserUserID + "=" + HttpUtility.UrlEncode(SecurityContext.CurrentAccount.ID.ToString()) + "&";
            query += FilesLinkUtility.AuthKey + "=" + EmailValidationKeyProvider.GetEmailKey(fileId + SecurityContext.CurrentAccount.ID) + "&";
            query += ThirdPartySelector.AppAttr + "=" + AppAttr;

            return uriBuilder.Uri + "?" + query;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:22,代码来源:GoogleDriveApp.cs


示例20: GenerateImageThumb

        internal void GenerateImageThumb(File file)
        {
            if (file == null || FileUtility.GetFileTypeByFileName(file.Title) != FileType.Image) return;

            try
            {
                using (var filedao = FilesIntegration.GetFileDao())
                {
                    using (var stream = filedao.GetFileStream(file))
                    {
                        var ii = new ImageInfo();
                        ImageHelper.GenerateThumbnail(stream, GetThumbPath(file.ID), ref ii, 128, 96, projectsStore);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("ASC.Web.Projects").Error(ex);
            }
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:20,代码来源:FileEngine.cs



注:本文中的ASC.Files.Core.File类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Domain.Task类代码示例发布时间:2022-05-24
下一篇:
C# Users.UserInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap