AlbedoDatabaseGenerator.Database.Export C# (CSharp) Méthode

Export() public méthode

Exports the database to a JSON file readable by the javascript web page that will help browsing the textures
public Export ( FileInfo _FileName ) : void
_FileName System.IO.FileInfo
Résultat void
        public void Export( FileInfo _FileName )
        {
            string	JSON = "{"+EOL;
            JSON += "	Entries : ["+EOL;
            foreach ( Entry E in m_Entries )
                JSON += E.Export( "		" );
            JSON += "	]"+EOL;
            JSON += "}"+EOL;

            using ( StreamWriter W = _FileName.CreateText() )
                W.Write( JSON );
        }

Usage Example

Exemple #1
0
        private void buttonExportJSON_Click(object sender, EventArgs e)
        {
//          string	OldFileName = GetRegKey( "JSONDatabaseFileName", Path.Combine( m_ApplicationPath, "Database.json" ) );
//          saveFileDialogExportJSON.InitialDirectory = Path.GetFullPath( OldFileName );
//          saveFileDialogExportJSON.FileName = Path.GetFileName( OldFileName );
//          if ( saveFileDialogExportJSON.ShowDialog( this ) != DialogResult.OK )
//              return;
//
//          SetRegKey( "JSONDatabaseFileName", saveFileDialogExportJSON.FileName );

            try
            {
//				m_Database.Export( new FileInfo( saveFileDialogExportJSON.FileName ) );

                FileInfo Target = new FileInfo(Path.Combine(m_Database.RootPath.FullName, "database.json"));
                m_Database.Export(Target);

                MessageBox("Success!\r\nJSON file was successfully exported to \"" + Target.FullName + "\"!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception _e)
            {
                MessageBox("An error occurred while exporting the database:\n\n", _e);
            }
        }