CultureAndRegionInfoBuilder.Save メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CultureAndRegionInfoBuilder.Save メソッドの意味・解説 

CultureAndRegionInfoBuilder.Save メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

現在の CultureAndRegionInfoBuilder オブジェクトXML 表現指定したファイル書き込みます

名前空間: System.Globalization
アセンブリ: sysglobl (sysglobl.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

filenamenull 参照 (Visual Basic では Nothing) です。

ArgumentException

filename空の文字列 ("") です。

ArgumentOutOfRangeException

現在の CultureAndRegionInfoBuilder オブジェクト格納されている DateTimeFormatInfo オブジェクト、TextInfo オブジェクト、または NumberFormatInfo オブジェクトプロパティの値が無効です。

解説解説
使用例使用例

Save メソッドおよび CreateFromLdml メソッドコード例次に示します

' This example demonstrates the CultureAndRegionInfoBuilder.Save and
 
' CreateFromLdml methods.
' Compile this example with a reference to sysglobl.dll.

Imports System
Imports System.Globalization
Imports System.IO
Imports System.Xml

Class Sample
    Public Shared Sub Main()
 
        Dim savedCARIB As String
 = "mySavedCARIB.xml"
        Dim msg1 As String
 = "The name of the original CultureAndRegionInfoBuilder"
 & _
                             " is ""{0}""."
        Dim msg2 As String
 = "Reconstituting the CultureAndRegionInfoBuilder object "
 & _
                             "from ""{0}""."
        Dim msg3 As String
 = "The name of the reconstituted CultureAndRegionInfoBuilder"
 & _
                             " is ""{0}""."

        ' Construct a new, privately used culture that extends the en-US
 culture 
        ' provided by the .NET Framework. In this sample, the CultureAndRegion-
        ' Types.Specific parameter creates a minimal CultureAndRegionInfoBuilder
 
        ' object that you must populate with culture and region information.

        Dim cib1 As CultureAndRegionInfoBuilder
 = Nothing
        Dim cib2 As CultureAndRegionInfoBuilder
 = Nothing
        
        Try
            cib1 = New CultureAndRegionInfoBuilder("x-en-US-sample",
 _
                                        CultureAndRegionModifiers.None)
        Catch ae As ArgumentException
            Console.WriteLine(ae)
            Return
        End Try
        
        ' Populate the new CultureAndRegionInfoBuilder object with culture
 information.
        Dim ci As New CultureInfo("en-US")
        cib1.LoadDataFromCultureInfo(ci)
        
        ' Populate the new CultureAndRegionInfoBuilder object with region
 information.
        Dim ri As New RegionInfo("US")
        cib1.LoadDataFromRegionInfo(ri)
        
        ' Display a property of the new custom culture.
        Console.Clear()
        Console.WriteLine(msg1, cib1.CultureName)
        
        ' Save the new CultureAndRegionInfoBuilder object in the specified
 file in
        ' LDML format. The file is saved in the same directory as the
 application 
        ' that calls the Save method.

        Console.WriteLine("Saving the custom culture to a file...")
        Try
            cib1.Save(savedCARIB)
        Catch exc As IOException
            Console.WriteLine("** I/O exception: {0}",
 exc.Message)
            Return
        End Try
        
        ' Create a new CultureAndRegionInfoBuilder object from the persisted
 file.
        Console.WriteLine(msg2, savedCARIB)
        Try
            cib2 = CultureAndRegionInfoBuilder.CreateFromLdml(savedCARIB)
        Catch xe As XmlException
            Console.WriteLine("** XML validation exception: {0}",
 xe.Message)
            Return
        End Try
        
        ' Display a property of the resonstituted custom culture.
        Console.WriteLine(msg3, cib2.CultureName)

        ' At this point you could call the Register method and make
 the reconstituted
        ' custom culture available to other applications. The mySavedCARIB.xml
 file
        ' remains on your computer.

    End Sub 'Main ' 
End Class 'Sample

'This code example produces the following results:
'
'The name of the original CultureAndRegionInfoBuilder is "x-en-US-sample".
'Saving the custom culture to a file...
'Reconstituting the CultureAndRegionInfoBuilder object from "mySavedCARIB.xml".
'The name of the reconstituted CultureAndRegionInfoBuilder is "x-en-US-sample".
'
// This example demonstrates the CultureAndRegionInfoBuilder.Save and
 
// CreateFromLdml methods.
// Compile this example with a reference to sysglobl.dll.

using System;
using System.Globalization;
using System.IO;
using System.Xml;

class Sample 
{
    public static void Main()
 
    {
    string savedCARIB = "mySavedCARIB.xml";
    string msg1 = "The name of the original CultureAndRegionInfoBuilder"
 +
                  " is \"{0}\".";
    string msg2 = "Reconstituting the CultureAndRegionInfoBuilder
 object " +
                  "from \"{0}\".";
    string msg3 = "The name of the reconstituted CultureAndRegionInfoBuilder"
 +
                  " is \"{0}\".";

// Construct a new, privately used culture that extends the en-US culture
 
// provided by the .NET Framework. In this sample, the CultureAndRegion-
// Types.Specific parameter creates a minimal CultureAndRegionInfoBuilder
 
// object that you must populate with culture and region information.

    CultureAndRegionInfoBuilder cib1 = null;
    CultureAndRegionInfoBuilder cib2 = null;
    try {
        cib1 = new CultureAndRegionInfoBuilder(
                           "x-en-US-sample", CultureAndRegionModifiers.None);
        }
    catch (ArgumentException ae)
        {
        Console.WriteLine(ae);
        return;
        }

// Populate the new CultureAndRegionInfoBuilder object with culture
 information.
    CultureInfo ci = new CultureInfo("en-US");
    cib1.LoadDataFromCultureInfo(ci);

// Populate the new CultureAndRegionInfoBuilder object with region information.
    RegionInfo  ri = new RegionInfo("US");
    cib1.LoadDataFromRegionInfo(ri);

// Display a property of the new custom culture.
    Console.Clear();
    Console.WriteLine(msg1, cib1.CultureName);

// Save the new CultureAndRegionInfoBuilder object in the specified
 file in
// LDML format. The file is saved in the same directory as the application
 
// that calls the Save method.

    Console.WriteLine("Saving the custom culture to a file...");
    try {
        cib1.Save( savedCARIB );
        }
    catch (IOException exc)
        {
        Console.WriteLine("** I/O exception: {0}", exc.Message);
        return;
        }

// Create a new CultureAndRegionInfoBuilder object from the persisted
 file.
    Console.WriteLine(msg2, savedCARIB);
    try {
        cib2 = CultureAndRegionInfoBuilder.CreateFromLdml( savedCARIB );
        }
    catch (XmlException xe)
        {
        Console.WriteLine("** XML validation exception: {0}", xe.Message);
        return;
        }

// Display a property of the resonstituted custom culture.
    Console.WriteLine(msg3, cib2.CultureName);

// At this point you could call the Register method and make the reconstituted
// custom culture available to other applications. The mySavedCARIB.xml
 file
// remains on your computer.
    }
}

/*
This code example produces the following results:

The name of the original CultureAndRegionInfoBuilder is "x-en-US-sample".
Saving the custom culture to a file...
Reconstituting the CultureAndRegionInfoBuilder object from "mySavedCARIB.xml".
The name of the reconstituted CultureAndRegionInfoBuilder is "x-en-US-sample".

*/
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CultureAndRegionInfoBuilder クラス
CultureAndRegionInfoBuilder メンバ
System.Globalization 名前空間
CreateFromLdml



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CultureAndRegionInfoBuilder.Save メソッド」の関連用語

CultureAndRegionInfoBuilder.Save メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CultureAndRegionInfoBuilder.Save メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS