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


C# System.Xml.XmlTextReader.ReadElementContentAs方法代码示例

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


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

示例1: initialize

        public static void initialize(Main pMain)
        {
            m_pMain = pMain;
            m_pWebClient = new CGWebClient();
            m_pWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(m_pWebClient_DownloadFileCompleted);
            m_pWebClient.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(m_pWebClient_DownloadProgressChanged);

            if (!System.IO.File.Exists(@"pak\Files\tile.p000"))
                m_pWebClient.DownloadFile(WEBSITE + "launcher/new_patch.xml", "patch.xml");
            else if (!System.IO.File.Exists(@"pak\World\_test$sample_1.p000"))
                m_pWebClient.DownloadFile(WEBSITE + "launcher/new_patch.xml", "patch.xml");
            else
                m_pWebClient.DownloadFile(WEBSITE + "launcher/patch.xml", "patch.xml");

            try
            {
                using (System.Xml.XmlTextReader pXmlTextReader = new System.Xml.XmlTextReader(Directory.GetCurrentDirectory() + "/patch.xml"))
                //using (System.Xml.XmlTextReader pXmlTextReader = new System.Xml.XmlTextReader( WEBSITE + "files/patch.xml"))
                {
                    int x = 0;

                    while (pXmlTextReader.ReadToFollowing("PATCHNODE"))
                    {
                        x++;
                        m_pMain.Status = "Interpreting Patch Information " + x + "...";
                        if (pXmlTextReader.MoveToFirstAttribute())
                        {
                            string strFilename = pXmlTextReader.GetAttribute("file").Replace("./", "");
                            string strCurrDir = System.IO.Directory.GetCurrentDirectory();
                            try
                            {
                                string Dir = Path.GetDirectoryName(strFilename);
                                if (!Directory.Exists(Dir) && Dir != "")
                                    Directory.CreateDirectory(Dir);
                            }
                            catch
                            {
                                m_pMain.Status = "Failed to create or read folder info.";
                            }
                            //foreach (string strTemp in strFilename.Split('/'))
                            //{
                            //    if (!strTemp.Contains("."))
                            //    {
                            //        System.IO.Directory.CreateDirectory(strTemp);
                            //        continue;
                            //    }
                            //}

                            uint nChecksum = 0;

                            if (pXmlTextReader.ReadToFollowing("CHECKSUM"))
                            {
                                nChecksum = (uint)pXmlTextReader.ReadElementContentAs(typeof(uint), null);
                            }
                            try
                            {
                                FileInfo FI = new FileInfo(strFilename);
                                if (strFilename.ToLower() == Path.GetFileName(Application.ExecutablePath).ToLower())
                                {
                                    FileInfo FI2 = new FileInfo(strFilename + "_");
                                    if (FI2.Exists)
                                        FI2.Delete();
                                    Thread.Sleep(500);
                                    FI.CopyTo(strFilename + "_");
                                    uint crc = getFileCrc(strFilename + "_");
                                    FI2 = new FileInfo(strFilename + "_");
                                    if (FI2.Exists)
                                        FI2.Delete();
                                    if (crc != nChecksum)
                                    {
                                        PatchSelf = true;
                                        m_pUpdateList.Add(strFilename);
                                    }
                                    continue;
                                }
                                if (!FI.Exists)
                                    m_pUpdateList.Add(strFilename);
                                else
                                {
                                    uint crc = getFileCrc(strFilename);
                                    if (crc != nChecksum)
                                    {
                                        m_pUpdateList.Add(strFilename);
                                    }
                                }
                            }
                            catch (Exception E)
                            {
                                if (E.Message.Contains("msvcr71.dll' because it is being used by another process"))
                                {
                                    //ignore because it's used by .net and gunz needs it...  note that this is a possible abuse for exploitation
                                }
                                else
                                {
                                    MessageBox.Show("Some of the files (" + strFilename + ") that need to be patched/edited are currently in use.  Make sure SoulHunterZ is closed.  If this error persists, restart your computer.", "Fatal Error");
                                    Application.Exit();
                                }
                            }

                            System.IO.Directory.SetCurrentDirectory(strCurrDir);
//.........这里部分代码省略.........
开发者ID:InitioGaming,项目名称:DPDragonfangLauncher,代码行数:101,代码来源:Updater.cs


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