当前位置: 首页>>代码示例>>C#>>正文


C# FileSystem.ImportData方法代码示例

本文整理汇总了C#中System.IO.FileSystem.ImportData方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.ImportData方法的具体用法?C# FileSystem.ImportData怎么用?C# FileSystem.ImportData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileSystem的用法示例。


在下文中一共展示了FileSystem.ImportData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        /// <summary>
        /// Load submission directory with new files, updates time
        /// </summary>
        public bool Update(Submission sub, IExternalSource files)
        {
            FileSystem fs = new FileSystem(m_ident);
            bool markcmp, unmarkcmp, defunct;

            //Get old sub
            Components.Submission oldsub = GetInfo(sub.ID);
            markcmp = (oldsub.Status == Components.Submission.UNGRADED &&
                      sub.Status == Components.Submission.GRADED);
            unmarkcmp = (oldsub.Status == Components.Submission.GRADED &&
                         sub.Status == Components.Submission.UNGRADED);
            defunct = (oldsub.Status != Components.Submission.DEFUNCT &&
                        sub.Status == Components.Submission.DEFUNCT);

            //Make sure toplevel zone directory exists
            CFile subdir = fs.GetFile(@"c:\subs");
            if (null == subdir)
                subdir = fs.CreateDirectory(@"c:\subs", true, null, false);

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            int courseID = new Assignments(m_ident).GetInfo(sub.AsstID).CourseID;
            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(courseID, true, null);
            foreach (CourseRole role in staff)
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
            perms.AddRange(CFilePermission.CreateOprFullAccess(sub.PrincipalID));

            //Create zone directory
            CFile esubdir;
            string zpath = @"c:\subs\" + sub.ID;
            if (null == (esubdir = fs.GetFile(zpath))) {
                esubdir = fs.CreateDirectory(zpath, false, perms, false);
                esubdir.SpecType = CFile.SpecialType.SUBMISSION;
                string name = new Principals(m_ident).GetInfo(sub.PrincipalID).Name;
                esubdir.Alias = String.Format("{0}: {1}",
                    name, GetNextSubmission(sub.AsstID, sub.PrincipalID));
                fs.UpdateFileInfo(esubdir, false);
            }
            //Update sub entry
            sub.LocationID = esubdir.ID;
            m_dp.UpdateSubmission(sub);

            //Load files
            try {
                fs.ImportData(zpath, files, false, false); //Import the data
            } catch (Exception) {
                throw new DataAccessException("Invalid external file source. This means the system does " +
                    "not understand how to extract files from the source. Please create a valid source");
            }

            //Verify submission structure
            VerifyFormat(sub.AsstID, zpath);

            //Log
            if (markcmp)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " completed", sub.ID);
            else if (unmarkcmp)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " incomplete", sub.ID);
            else if (defunct)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " defunct", sub.ID);

            return true;
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:66,代码来源:submissions.cs

示例2: cmdUpload_Click

        private void cmdUpload_Click(object sender, System.EventArgs e)
        {
            if (fiUpload.PostedFile.FileName.Length == 0) {
                DisplayMessage("Please select a file to upload");
                return;
            }

            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            string name = Path.GetFileName(fiUpload.PostedFile.FileName);
            SingleFileSource sfs = new SingleFileSource(name);

            try {
                sfs.CreateSource(fiUpload.PostedFile.InputStream);
                fs.ImportData(GetCurrentPath(), sfs, true, false);
            } catch (FileOperationException er) {
                DisplayMessage(er.Message);
            }

            BindFileGrid();
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:20,代码来源:filebrowser.ascx.cs


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