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


C# System.Xml.XmlTextWriter.Close方法代码示例

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


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

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int report_uid;
            int new_state;

            if (int.TryParse(Request.QueryString["report_uid"], out report_uid) == false)
            {
                return;
            }

            if (int.TryParse(Request.QueryString["state"], out new_state) == false)
                new_state = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Outputs");

                DB.UpdateReportState(report_uid, new_state);

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:30,代码来源:UpdateReportState.aspx.cs

示例2: CriarArquivoXML

        /// <summary>
        /// Método para criação do Arquivo XML com Configurações do usuário.
        /// </summary>
        public static void CriarArquivoXML()
        {
            try
            {
                System.Xml.XmlTextWriter xtrPrefs = new System.Xml.XmlTextWriter(Directories.UserPrefsDirectory + 
                    @"\UserPrefs.config", System.Text.Encoding.UTF8);

                // Inicia o documento XML.
                xtrPrefs.WriteStartDocument();

                // Escreve elemento raiz.
                xtrPrefs.WriteStartElement("Directories");
                // Escreve sub-Elementos.
                xtrPrefs.WriteElementString("Starbound", Directories.StarboundDirectory);
                xtrPrefs.WriteElementString("Mods", Directories.ModsDirectory);
                // Encerra o elemento raiz.
                xtrPrefs.WriteEndElement();
                // Escreve o XML para o arquivo e fecha o objeto escritor.
                xtrPrefs.Close();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);

            }
        }
开发者ID:MiCLeal,项目名称:Mod-Editor--Starbound,代码行数:29,代码来源:XmlPrefs.cs

示例3: Main

        static void Main(string[] args)
        {


            var items = typeof(string).Assembly.GetTypes().Take(100);
            var items2 = items.Select(i => new { i.Name, i.IsClass, i.IsEnum, i.IsValueType });


            var datatable = Isotope.Data.DataUtil.DataTableFromEnumerable(items2);

            string out_filename = "out.xaml";
            var encoding = System.Text.Encoding.UTF8;

            var x = new System.Xml.XmlTextWriter(out_filename, encoding);

            var repdef = new Isotope.Reporting.ReportDefinition();


            repdef.ReportHeaderDefinition.ReportTitle.TextStyle.FontSize = 18.0;
            repdef.ReportHeaderDefinition.ReportTitle.TextStyle.FontWeight = Isotope.Reporting.FontWeight.Bold;
            repdef.ReportHeaderDefinition.HeaderText.TextStyle.FontSize = 8.0;

            var colstyle1 = new Isotope.Reporting.TableColumnStyle();
            colstyle1.DetailTextStyle.FontWeight = Isotope.Reporting.FontWeight.Bold;
            colstyle1.HorzontalAlignment = Isotope.Reporting.HorzontalAlignment.Right;
            colstyle1.Width = 150;

            repdef.Table.ColumnStyles.Add(colstyle1);

            repdef.Table.TableStyle.CellSpacing = 10;
            repdef.WriteXML(x,datatable);
            x.Close();

        }
开发者ID:saveenr,项目名称:saveenr,代码行数:34,代码来源:Program.cs

示例4: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();

                writer.WriteStartElement("Project");
                writer.WriteStartElement("Items");

                Dictionary<int, sProject> projectList;
                DB.LoadProject(out projectList);

                foreach (KeyValuePair<int, sProject> item in projectList)
                {
                    writer.WriteStartElement("Item");
                    writer.WriteAttributeString("uid", item.Key.ToString());
                    writer.WriteAttributeString("name", item.Value.name);
                    writer.WriteEndElement();
                }

                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:29,代码来源:ProjectList.aspx.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int callstack_uid;

            if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
                callstack_uid = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Callstack");

                DB.LoadCallstack(callstack_uid,
                    delegate(int depth, string funcname, string fileline)
                    {
                        writer.WriteStartElement("Singlestep");
                        writer.WriteAttributeString("depth", depth.ToString());
                        this.WriteCData(writer, "Funcname", funcname);
                        this.WriteCData(writer, "Fileline", fileline);
                        writer.WriteEndElement();
                    }
                );

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:33,代码来源:CallstackView.aspx.cs

示例6: ModifyProjectFile

        public static void ModifyProjectFile(string filename)
        {
            if (!filename.ToLower().EndsWith("proj"))
            {
                throw new System.ArgumentException("Internal Error: ModifyProjectFile called with a file that is not a project");
            }

            Console.WriteLine("Modifying Project : {0}", filename);

            // Load the Project file
            var doc = System.Xml.Linq.XDocument.Load(filename);

            // Modify the Source Control Elements
            RemoveSCCElementsAttributes(doc.Root);

            // Remove the read-only flag
            var original_attr = System.IO.File.GetAttributes(filename);
            System.IO.File.SetAttributes(filename, System.IO.FileAttributes.Normal);

            // Write out the XML
            using (var writer = new System.Xml.XmlTextWriter(filename, Encoding.UTF8))
            {
                writer.Formatting = System.Xml.Formatting.Indented;
                doc.Save(writer);
                writer.Close();
            }

            // Restore the original file attributes
            System.IO.File.SetAttributes(filename, original_attr);
        }
开发者ID:redspiked,项目名称:VS_unbind_source_control,代码行数:30,代码来源:Program.cs

示例7: IsolatedStorage_Read_and_Write_Sample

        public static void IsolatedStorage_Read_and_Write_Sample()
        {
            string fileName = @"SelfWindow.xml";

            IsolatedStorageFile storFile = IsolatedStorageFile.GetUserStoreForDomain();
            IsolatedStorageFileStream storStream = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write);
            System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(storStream, Encoding.UTF8);
            writer.WriteStartDocument();

            writer.WriteStartElement("Settings");

            writer.WriteStartElement("UserID");
            writer.WriteValue(42);
            writer.WriteEndElement();
            writer.WriteStartElement("UserName");
            writer.WriteValue("kingwl");
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
            storStream.Close();

            string[] userFiles = storFile.GetFileNames();

            foreach(var userFile in userFiles)
            {
                if(userFile == fileName)
                {
                    var storFileStreamnew =  new IsolatedStorageFileStream(fileName,FileMode.Open,FileAccess.Read);
                    StreamReader storReader = new StreamReader(storFileStreamnew);
                    System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(storReader);

                    int UserID = 0;
                    string UserName = null;

                    while(reader.Read())
                    {
                        switch(reader.Name)
                        {
                            case "UserID":
                                UserID = int.Parse(reader.ReadString());
                                break;
                            case "UserName":
                                UserName = reader.ReadString();
                                break;
                            default:
                                break;
                        }
                    }

                    Console.WriteLine("{0} {1}", UserID, UserName);

                    storFileStreamnew.Close();
                }
            }
            storFile.Close();
        }
开发者ID:xxy1991,项目名称:cozy,代码行数:59,代码来源:D8IsolatedStorageReadAndWrite.cs

示例8: WriteConfig

 // Lecture de la configuration
 public static void WriteConfig()
 {
     string config_file = "config.xml";
     var newconf = new System.Xml.XmlTextWriter(config_file, null);
     newconf.WriteStartDocument();
     newconf.WriteStartElement("config");
     newconf.WriteElementString("last_update", LastUpdate.ToShortDateString());
     newconf.WriteElementString("auth_token", AuthToken);
     newconf.WriteEndElement();
     newconf.WriteEndDocument();
     newconf.Close();
 }
开发者ID:remyoudompheng,项目名称:flickrstats,代码行数:13,代码来源:Program.cs

示例9: ReadConfig

        // Lecture de la configuration
        static void ReadConfig()
        {
            string config_file = "config.xml";
            if (!System.IO.File.Exists(config_file))
            {
                var newconf = new System.Xml.XmlTextWriter(config_file, null);
                newconf.WriteStartDocument();
                newconf.WriteStartElement("config");
                newconf.WriteElementString("last_update", "0");
                newconf.WriteElementString("auth_token", "");
                newconf.WriteEndElement();
                newconf.WriteEndDocument();
                newconf.Close();
            }

            var conf = new System.Xml.XmlTextReader(config_file);
            string CurrentElement = "";
            while (conf.Read())
            {
                switch(conf.NodeType) {
                    case System.Xml.XmlNodeType.Element:
                        CurrentElement = conf.Name;
                        break;
                    case System.Xml.XmlNodeType.Text:
                    if (CurrentElement == "last_update")
                        LastUpdate = DateTime.Parse(conf.Value);
                    if (CurrentElement == "auth_token")
                        AuthToken = conf.Value;
                        break;
                }
            }
            conf.Close();

            // On vérifie que le token est encore valide
            if (AuthToken.Length > 0)
            {
                var flickr = new Flickr(Program.ApiKey, Program.SharedSecret);
                try
                {
                    Auth auth = flickr.AuthCheckToken(AuthToken);
                    Username = auth.User.UserName;
                }
                catch (FlickrApiException ex)
                {
                    //MessageBox.Show(ex.Message, "Authentification requise",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    AuthToken = "";
                }
            }
        }
开发者ID:remyoudompheng,项目名称:flickrstats,代码行数:51,代码来源:Program.cs

示例10: saveButton_Click

        private void saveButton_Click(object sender, EventArgs e)
        {
            string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DichMusicHelperPathSettings.xml";

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(settingsFile, System.Text.Encoding.Unicode))
            {
                writer.WriteStartElement("PathSettings");
                writer.WriteAttributeString("Path", pathTextBox.Text);
                writer.WriteAttributeString("CreateFolder", createFolderBox.Checked.ToString());
                writer.WriteEndElement();
                writer.Close();
            }

            this.Close();
        }
开发者ID:kishtatik,项目名称:MusicFromVKWalls,代码行数:15,代码来源:PathSettingForm.cs

示例11: UpdateConfig

 /// <summary>
 /// 保存Config参数
 /// </summary>
 public static void UpdateConfig(string name, string nKey, string nValue)
 {
     if (ReadConfig(name, nKey) != "")
     {
         System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
         XmlDoc.Load(HttpContext.Current.Server.MapPath(name + ".config"));
         System.Xml.XmlNodeList elemList = XmlDoc.GetElementsByTagName(nKey);
         System.Xml.XmlNode mNode = elemList[0];
         mNode.InnerText = nValue;
         System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(new System.IO.StreamWriter(HttpContext.Current.Server.MapPath(name + ".config")));
         xw.Formatting = System.Xml.Formatting.Indented;
         XmlDoc.WriteTo(xw);
         xw.Close();
     }
 }
开发者ID:WZDotCMS,项目名称:WZDotCMS,代码行数:18,代码来源:XmlCOM.cs

示例12: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int project_uid;

            if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
                project_uid = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();

                writer.WriteStartElement("Report");
                writer.WriteAttributeString("project", project_uid.ToString());

                writer.WriteStartElement("Items");

                DB.LoadReportDeleted(project_uid,
                    delegate(int report_uid, string login_id, string ipaddr, DateTime reported_time, string relative_time, int callstack_uid, string funcname, string version, string filename, string assigned, string uservoice, int num_comments)
                    {
                        writer.WriteStartElement("Item");

                        writer.WriteAttributeString("report_uid", report_uid.ToString());
                        writer.WriteAttributeString("login_id", login_id);
                        writer.WriteAttributeString("ipaddr", ipaddr);
                        writer.WriteAttributeString("reported_time", reported_time.ToString());
                        writer.WriteAttributeString("relative_time", relative_time);
                        writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
                        writer.WriteAttributeString("assigned", assigned);
                        writer.WriteAttributeString("num_comments", num_comments.ToString());
                        this.WriteCData(writer, "Funcname", funcname);
                        this.WriteCData(writer, "Version", version);
                        this.WriteCData(writer, "Filename", filename);
                        this.WriteCData(writer, "Uservoice", uservoice);

                        writer.WriteEndElement();
                    }
                );
                writer.WriteEndElement(); // Items
                writer.WriteEndElement(); // Report
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:48,代码来源:ReportDeleted.aspx.cs

示例13: Serialize

 /// <summary>
 /// 序列化成xml字符串
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>序列化后的字符串</returns>
 public static string Serialize(object obj)
 {
     XmlSerializer xs = new XmlSerializer(obj.GetType());
     using (MemoryStream ms = new MemoryStream())
     {
         System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(ms, System.Text.Encoding.UTF8);
         xtw.Formatting = System.Xml.Formatting.Indented;
         xs.Serialize(xtw, obj);
         ms.Seek(0, SeekOrigin.Begin);
         using (StreamReader sr = new StreamReader(ms))
         {
             string str = sr.ReadToEnd();
             xtw.Close();
             ms.Close();
             return str;
         }
     }
 }
开发者ID:tihou,项目名称:Fx.InformationPlatform.,代码行数:23,代码来源:Serialize.cs

示例14: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DichMusicHelperProxySettings.xml";

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(settingsFile, System.Text.Encoding.Unicode))
            {
                writer.WriteStartElement("ProxySettings");
                writer.WriteAttributeString("Server", serverBox.Text);
                writer.WriteAttributeString("Port", portBox.Text);
                writer.WriteAttributeString("Login", loginBox.Text);
                writer.WriteAttributeString("Password", passwordBox.Text);
                writer.WriteAttributeString("UseProxy", useProxyBox.Checked.ToString());
                writer.WriteEndElement();
                writer.Close();
            }

            this.Close();
        }
开发者ID:kishtatik,项目名称:MusicFromVKWalls,代码行数:18,代码来源:ProxyForm.cs

示例15: saveDataTable

 public static void saveDataTable(DataTable data, string filePath)
 {
     // Create the FileStream to write with.
     System.IO.FileStream myFileStream = new System.IO.FileStream
        (filePath, System.IO.FileMode.Create);
     // Create an XmlTextWriter with the fileStream.
     System.Xml.XmlTextWriter myXmlWriter =
        new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
     // Write to the file with the WriteXml method.
     try
     {
         data.WriteXml(myXmlWriter);
     }
     finally
     {
         myXmlWriter.Close();
     }
 }
开发者ID:mescalitog,项目名称:xTangoFacturas,代码行数:18,代码来源:Commons.cs


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