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


C# FileSystem.GetFile方法代码示例

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


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

示例1: Discover

        public string Discover(AutoEvaluation eval, out double points, out int time, out int count)
        {
            //Get Perl
            IExternalTool perl = ExternalToolFactory.GetInstance().CreateExternalTool("Perl",
                "5.0", ExternalToolFactory.VersionCompare.ATLEAST);
            if (perl == null)
                throw new JUnitToolException(
                    "Unable to find Perl v5.0 or later. Please check the installation or contact the administrator");

            //Get all files on the disk
            string tpath = ExportToTemp(eval);

            //Run disco program
            perl.Arguments = "jdisco.pl i";
            perl.Execute(tpath);
            Directory.Delete(tpath, true);

            //Validate XML
            string xmltests = perl.Output;
            XmlWizard xmlwiz = new XmlWizard();
            if (!xmlwiz.ValidateXml(xmltests, Path.Combine(Globals.WWWDirectory, "Xml/testsuite.xsd")))
                throw new JUnitToolException("Invalid JUnit Test Suite. Check to make sure the test suite conforms to FrontDesk standards");

            //Write XML
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile zone = fs.GetFile(eval.ZoneID);
            string tspath = Path.Combine(zone.FullPath, "__testsuite.xml");
            CFile xmldesc = fs.GetFile(tspath);
            if (xmldesc == null)
                xmldesc = fs.CreateFile(tspath, false, null);
            xmldesc.Data = xmltests.ToCharArray();
            fs.Edit(xmldesc);
            fs.Save(xmldesc);

            //Copy disco program over
            CFile.FileList dfiles = new CFile.FileList();
            dfiles.Add(fs.GetFile(@"c:\system\junit\jdisco.pl"));
            dfiles.Add(fs.GetFile(@"c:\system\junit\JUnitDiscover.class"));
            dfiles.Add(fs.GetFile(@"c:\system\junit\JUnitDiscover$ClassFileFilter.class"));
            fs.CopyFiles(zone, dfiles, true);

            //Get suite metadata
            GetSuiteInfo(xmltests, out points, out time, out count);

            //Punt all previous results
            RemoveResults(eval);

            return xmltests;
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:49,代码来源:junittool.cs

示例2: LoadFileBrowser

        public void LoadFileBrowser()
        {
            int i=0;
            tvFiles.Nodes.Clear();
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            foreach(string droot in m_roots) {
                CFile dirroot = fs.GetFile(droot);

                TreeNode root = new TreeNode();
                root.Text = dirroot.Alias;
                root.ImageUrl = GetFolderIcon(dirroot);
                root.NodeData = dirroot.FullPath;
                root.Expandable = ExpandableValue.Always;
                tvFiles.Nodes.Add(root);

                if (i == 0 && ViewState["gridpath"] == null) {
                    ViewState["gridpath"] = dirroot.FullPath;
                    ExpandTreeNode(root);
                }
                ++i;
            }

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

示例3: ReDiscover

        public string ReDiscover(AutoEvaluation eval, out double points, out int time, out int count)
        {
            string xmltests;
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            CFile zone = fs.GetFile(eval.ZoneID);
            CFile xmldesc = fs.GetFile(Path.Combine(zone.FullPath, "__testsuite.xml"));
            if (xmldesc == null)
                throw new JUnitToolException("No proper JUnit Test Suite uploaded");

            fs.LoadFileData(xmldesc);
            xmltests = new string(xmldesc.Data);

            GetSuiteInfo(xmltests, out points, out time, out count);

            return xmltests;
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:17,代码来源:junittool.cs

示例4: tvFiles_SelectedIndexChange

        protected void tvFiles_SelectedIndexChange(object sender, TreeViewSelectEventArgs e)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            TreeNode selnode = tvFiles.GetNodeFromIndex(e.NewNode);
            ViewState["gridpath"] = fs.GetFile(selnode.NodeData).FullPath;

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

示例5: ParseSubjXmlResults

        protected SubjResult.SubjResultList ParseSubjXmlResults(string xmlresults, Submission sub)
        {
            SubjResult.SubjResultList ress = new SubjResult.SubjResultList();
            XPathNavigator xnav = new XmlWizard().GetXPathNavigator(xmlresults);
            FileSystem fs = new FileSystem(m_ident);
            CFile zone = fs.GetFile(sub.LocationID);

            xnav.MoveToFirstChild(); xnav.MoveToFirstChild();
            XPathNavigator comments = xnav.Clone();
            while (comments.MoveToNext()) {
                SubjResult res = new SubjResult();
                XPathNavigator comment = comments.Clone();
                comment.MoveToFirstChild();

                string subjtype = comment.Value; comment.MoveToNext();
                switch (subjtype) {
                case "Warning":
                    res.SubjType = Rubric.WARNING;
                    break;
                case "Error":
                    res.SubjType = Rubric.ERROR;
                    break;
                case "Good":
                    res.SubjType = Rubric.GOOD;
                    break;
                };

                res.Points = Convert.ToDouble(comment.Value); comment.MoveToNext();
                res.Comment = comment.Value; comment.MoveToNext();

                string filename = comment.Value; comment.MoveToNext();
                if (filename.StartsWith(@".\"))
                    filename = filename.Substring(2, filename.Length-2);
                CFile file = fs.GetFile(Path.Combine(zone.FullPath, filename));
                if (file != null) {
                    res.FileID = file.ID;
                    res.Line = Convert.ToInt32(comment.Value);
                    ress.Add(res);
                }
            }

            return ress;
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:43,代码来源:testcenter.cs

示例6: Delete

        /// <summary>
        /// Delete the assignment
        /// </summary>
        public bool Delete(int asstID)
        {
            FileSystem fs = new FileSystem(m_ident);
            Submissions subda = new Submissions(m_ident);
            Evaluations evalda = new Evaluations(m_ident);
            Results resultda = new Results(m_ident);
            Groups groupda = new Groups(m_ident);
            AutoJobs jobda = new AutoJobs(m_ident);

            Assignment asst = GetInfo(asstID);

            //Check permission
            Authorize(asst.CourseID, "delete", asstID, null);

            //Take auto jobs
            IProviderTransaction tran = m_dp.BeginTransaction();
            AutoJob.AutoJobList jobs = GetAutoJobs(asstID, tran);
            foreach (AutoJob job in jobs)
                jobda.Finish(job.ID, tran);
            m_dp.CommitTransaction(tran);

            //Take submissions and results
            Components.Submission.SubmissionList allsubs = GetSubmissions(asstID);
            foreach (Components.Submission sub in allsubs)
                subda.Delete(sub.ID);

            //Take rubric
            Rubric rub = GetRubric(asstID);
            new Rubrics(m_ident).Delete(rub.ID);

            //Take evaluations
            Evaluation.EvaluationList allevals = GetEvals(asstID);
            foreach (Evaluation eval in allevals)
                evalda.Delete(eval.ID);

            //Take groups
            Group.GroupList groups = GetGroups(asstID);
            foreach (Group group in groups)
                groupda.Delete(group.PrincipalID, asstID);

            //Take assignment
            m_dp.DeleteAssignment(asstID);

            //Take content
            CFile content = fs.GetFile(asst.ContentID);
            fs.DeleteFile(content);

            //Log
            Log("Deleted assignment: " + asst.Description, asst.ID);

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

示例7: tb_CreateFolder

        private bool tb_CreateFolder(object sender, EventArgs e)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile par = fs.GetFile(GetCurrentFileID());
            string path = par.FullPath + @"\" + "newfolder";

            try {
                CFile fold = fs.CreateDirectory(path, false, null);
                fold.Alias = "New Folder";
                fold.Name = fold.ID + fold.Name;
                fs.UpdateFileInfo(fold, false);
            } catch (FileOperationException er) {
                PageError(er.Message);
                return false;
            }

            TreeNode node = GetCurrentNode();
            LoadNode(node);
            node.Expanded = true;

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

示例8: DoDelete

        private void DoDelete(int subID, int locid)
        {
            FileSystem fs = new FileSystem(m_ident);

            //Take results
            Results resultda = new Results(m_ident);
            Result.ResultList ress = GetResults(subID);
            foreach (Result res in ress)
                resultda.Delete(res.ID);

            //Take any tests queued
            AutoJobs jobda = new AutoJobs(m_ident);
            AutoJobTest.AutoJobTestList tests = jobda.GetSubTests(subID);
            foreach (AutoJobTest test in tests)
                jobda.FinishTest(test);

            //Take the submission record
            m_dp.DeleteSubmission(subID);

            //Take the files
            CFile subdir = fs.GetFile(locid);
            if (subdir != null)
                fs.DeleteFile(subdir);
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:24,代码来源:submissions.cs

示例9: BindData

        private void BindData()
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile file = fs.GetFile(GetFileID());

            if (!GetStudentMode()) {
                divPerms.Visible = true;
                ucFilePerms.FileID = file.ID;
                ucFilePerms.BindData();
            } else
                divPerms.Visible = false;

            cmdUpdate.Visible = iDirections.Visible = divUpload.Visible = !GetStudentMode();
            txtName.Text = file.Alias;
            if (file.IsDirectory()) {
                divData.Visible = false;
                txtType.Enabled = false;
                txtType.Text = "Folder";
            }
            else {
                divData.Visible = true;

                txtType.Enabled = true;
                txtType.Text = Path.GetExtension(file.Name);
                txtDesc.Text = file.Description;

                if (txtType.Text == ".url") {
                    fs.LoadFileData(file);
                    string url = new string(file.Data);
                    txtUrl.Text = url;
                    lnkEdit.Attributes.Add("onClick",
                        @"window.open('" + url + "', '"+"Mike"[email protected]"', 'width=800, height=600 " +
                        @", scrollbars=yes, menubar=yes, resizable=yes, status=yes, toolbar=yes')");
                    lnkDownload.Enabled = false;
                    rdbData.Checked = false; rdbLink.Checked = true;
                } else {
                    txtUrl.Text = "";
                    rdbData.Checked = true; rdbLink.Checked = false;
                    lnkEdit.Attributes.Add("onClick",
                        @"window.open('Controls/Filesys/viewfile.aspx?FileID=" + file.ID +
                        @"', '"[email protected]"', 'width=770, height=580')");
                    lnkDownload.Attributes.Add("onClick",
                        @"window.open('Controls/Filesys/dlfile.aspx?FileID=" + file.ID +
                        @"', '"[email protected]"', 'width=770, height=580')");
                    lnkDownload.Enabled = true;
                }
            }

            txtType.Enabled = txtDesc.Enabled = txtName.Enabled =
                !GetStudentMode();
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:51,代码来源:content.ascx.cs

示例10: cmdDataUpload_Click

        private void cmdDataUpload_Click(object sender, EventArgs e)
        {
            if (ufContent.PostedFile.ContentLength > 0) {
                FileSystem fs = new FileSystem(Globals.CurrentIdentity);
                CFile file = fs.GetFile(GetFileID());

                try {
                    fs.Edit(file);

                    byte[] content = Globals.ReadStream(
                        ufContent.PostedFile.InputStream, ufContent.PostedFile.ContentLength);
                    file.RawData = content;
                    fs.Save(file);

                    file.Name = file.ID + Path.GetFileName(ufContent.PostedFile.FileName);
                    fs.UpdateFileInfo(file, false);
                } catch (Exception er) {
                    PageUpError(er.Message);
                }

                if (Refresh != null)
                    Refresh(this, new RefreshEventArgs("", true, false));
            }
            else
                PageUpError("Must specify a local file to upload");

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

示例11: GetFiles

 private CFile.FileList GetFiles(string files)
 {
     string[] tokens = files.Split("|".ToCharArray());
     CFile.FileList flist = new CFile.FileList();
     FileSystem fs = new FileSystem(Globals.CurrentIdentity);
     foreach (string sfile in tokens)
         if (sfile.Length > 0)
             flist.Add(fs.GetFile(Convert.ToInt32(sfile)));
     return flist;
 }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:10,代码来源:viewfile.aspx.cs

示例12: cmdPaste_ButtonClick

        protected bool cmdPaste_ButtonClick(object sender, EventArgs ea)
        {
            TreeNode destnode;
            ClipBoard cb;
            FileSystem fs;

            cb = (ClipBoard) ViewState["clipboard"];
            if (cb == null) {
                DisplayMessage("Clipboard empty. You must cut/copy files before pasting has an effect");
                return true;
            }

            fs = new FileSystem(Globals.CurrentIdentity);
            destnode = tvFiles.GetNodeFromIndex(tvFiles.SelectedNodeIndex);
            CFile dest = fs.GetFile((string)ViewState["gridpath"]);

            try {
                if (cb.Move)
                    fs.MoveFiles(dest, cb.Files, false);
                else
                    fs.CopyFiles(dest, cb.Files, false);
            }
            catch (FileOperationException e) {
                DisplayMessage(e.Message);
                return false;
            }

            UpdateTreeNode(destnode, true);
            BindFileGrid();
            ViewState["clipboard"] = null;
            BindClipBoard();

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

示例13: CreateZone

        protected bool CreateZone(IZoneComponent eval)
        {
            FileSystem fs = new FileSystem(m_ident);
            DataSet desc = new DataSet();

            //Create initial zone directory
            string zpath = Path.Combine(TestConfig.LocalZonePath,
                m_prefix + eval.GetZoneID().ToString());
            Directory.CreateDirectory(zpath);

            //Export the zone files into local store
            IExternalSink zdir = new OSFileSystemSink();

            zdir.CreateSink("");
            try {
                desc = fs.ExportData(zpath, fs.GetFile(eval.GetZoneID()), zdir, false);

                //Write XML descriptor
                desc.Tables["Export"].Rows[0]["Mod"] = eval.GetZoneModified().Ticks;
                desc.WriteXml(Path.Combine(zpath, ZONE_FILE));
                m_logger.Log("Zone retrieved successfully");

            } catch (FileOperationException e) {
                m_logger.Log("File error: " + e.Message, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            } catch (DataAccessException er) {
                m_logger.Log("Data error: " + er.Message, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            } catch (Exception e) {
                m_logger.Log("Unexpected error: " + e.Message, TestLogger.LogType.ERROR);
                m_logger.Log("Trace: " + e.StackTrace, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            }

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

示例14: LoadFolderNode

        private void LoadFolderNode(TreeNode par, int fileID)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            par.Nodes.Clear();
            CFile.FileList cdir;

            try {
                cdir = fs.ListDirectory(fs.GetFile(fileID));
            } catch (CustomException er) {
                PageError(er.Message); return;
            }

            foreach (CFile file in cdir) {
                if (file.IsDirectory())
                    AddFolderNode(par.Nodes, file);
                else
                    AddDocumentNode(par.Nodes, file);
            }
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:19,代码来源:coursematrix.ascx.cs

示例15: LoadCourseNode

        private void LoadCourseNode(TreeNode par, int courseID)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            Courses courseda = new Courses(Globals.CurrentIdentity);
            Course course = courseda.GetInfo(courseID);

            par.Nodes.Clear();
            //Load announcement folder
            if (!StudentMode)
                AddAnnFolderNode(par.Nodes, courseID);

            //Load content
            CFile.FileList cdir = fs.ListDirectory(fs.GetFile(course.ContentID));
            foreach (CFile file in cdir) {
                if (file.IsDirectory())
                    AddFolderNode(par.Nodes, file);
                else
                    AddDocumentNode(par.Nodes, file);
            }

            //Load assignments
            Assignment.AssignmentList assts;
            if (StudentMode)
                assts = courseda.GetStudentAssignments(courseID);
            else
                assts = courseda.GetAssignments(courseID);
            foreach (Assignment asst in assts)
                AddAsstNode(par.Nodes, asst);

            //Add section folder
            if (!StudentMode) {
                AddBackupsNode(par.Nodes, courseID);
                AddSectionFolderNode(par.Nodes, courseID, "Users and Sections");
                AddPermNode(par.Nodes, courseID);
            }
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:36,代码来源:coursematrix.ascx.cs


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