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


C# FileSystem.Save方法代码示例

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


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

示例1: Export

        /// <summary>
        /// Export data into CSV format
        /// </summary>
        public CFile Export(FileSystem fs, ExportRow.ExportRowList rows)
        {
            int i;
            MemoryStream csvstream = new MemoryStream();
            StreamWriter csvwriter = new StreamWriter(csvstream);

            //Write the data out in CSV style rows
            foreach (ExportRow row in rows) {
                for (i = 0; i < row.Fields.Count; i++) {
                    csvwriter.Write(row.Fields[i]);
                    if (i < row.Fields.Count-1)
                        csvwriter.Write(",");
                }
                csvwriter.WriteLine();
            }
            csvwriter.Flush();

            //Commit to a temp file within the FS
            //Create a temp file
            Guid guid = Guid.NewGuid();
            CFile expfile = fs.CreateFile(@"c:\system\export\" + guid.ToString(), false,
                new CFilePermission.FilePermissionList() );
            expfile.Name = expfile.ID + ".csv";
            fs.UpdateFileInfo(expfile, false);

            //Commit the data
            csvstream.Seek(0, SeekOrigin.Begin);
            expfile.RawData = Globals.ReadStream(csvstream, (int) csvstream.Length);
            fs.Edit(expfile);
            fs.Save(expfile);

            csvwriter.Close();

            return expfile;
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:38,代码来源:csvexporter.cs

示例2: 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

示例3: cmdUrlUpload_Click

        private void cmdUrlUpload_Click(object sender, System.EventArgs e)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile file = fs.GetFile(GetFileID());

            try {
                //Save Url data
                fs.Edit(file);
                file.Data = txtUrl.Text.ToCharArray();
                fs.Save(file);
                //Update file
                file.Name = file.ID + ".url";
                fs.UpdateFileInfo(file, false);
            } catch (Exception er) {
                PageLinkError(er.Message);
            }

            BindData();

            if (Refresh != null)
                Refresh(this, new RefreshEventArgs("", true, false));
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:22,代码来源:content.ascx.cs

示例4: 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


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