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


C# Settings.SaveToFile方法代码示例

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


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

示例1: Main


//.........这里部分代码省略.........
        Settings.Initialise();
      }
      catch( Exception ex )
      {
        Log.AddEntry( ex );
        MessageBox.Show( ex.Message,
                         "Settings Error",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Error );
      }

      // P4.
      string envVarPath = ( Environment.GetEnvironmentVariable( "path" ) ?? "" ).ToLower();
      string[] envVarPathEntries = envVarPath.Split( ';' );
      string p4Path = null;

      foreach( string entry in envVarPathEntries )
      {
        if( File.Exists( entry + @"\p4.exe" ) )
        {
          p4Path = entry;
          break;
        }
      }

      if( p4Path == null )
      {
        MessageBox.Show(
          "Could not find p4.exe in any path in the PATH environment-variable, please add " +
            "the path where p4.exe is located to the PATH environment-variable.",
          "Perforce Error",
          MessageBoxButtons.OK,
          MessageBoxIcon.Error );

        return;
      }

      Log.AddEntry(
        Log.EntryType.INFO,
        "P4 path: " + p4Path );

      // Db.
      try
      {
        // Try connect to the databases.
        try
        {
          DbConnection = DbConnection.Instance;
        }
        catch( Exception ex )
        {
          Log.AddEntry( ex );
          
          MessageBox.Show(
            ex.Message,
            "Database Error",
            MessageBoxButtons.OK,
            MessageBoxIcon.Error );

          return;
        }

        // Connected to the DB?
        if( DbConnection.Critr.State != System.Data.ConnectionState.Open )
        {
          Log.AddEntry(
            Log.EntryType.ERROR,
            "Failed to connect to the database." );

          MessageBox.Show(
            "Failed to connect to the database.",
            "Database Error",
            MessageBoxButtons.OK,
            MessageBoxIcon.Error );
        }
      }
      catch( Exception ex )
      {
        Log.AddEntry( ex );

        MessageBox.Show(
          ex.Message,
          "Database Error",
          MessageBoxButtons.OK,
          MessageBoxIcon.Error );
      }

      // Init some things.
      UserCollection = new UserCollection();
      ChangelistHelpers.LoadChangelistsFromDb();

      // Start the app.
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault( false );
      Application.Run( new MainForm() );

      // Shutdown.
      Settings.SaveToFile();
      Log.AddInfo( "Shutdown." );
    }
开发者ID:grae22,项目名称:Critr,代码行数:101,代码来源:Program.cs


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