????? ??????? Visual Basic .NET ?? 2005 Visual Basic ?????? ??? ????? ???????? ??? ResourceWriter ?????? ??????? ??? ????? ???????? ??? ResourceManager

?????? ????????? ?????? ?????????
???? ???????: 820659 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ????? ??? ????? ???????? ??? ResourceWriter ?????? ??????? ??? ????? ???????? ??? ResourceManager.

???? ????? ResourceWriter ????? ??????? ?? IResourceWriter ?????. ????? ????? ??????? ?? ????? ??? ????? ?????? ??????? ??????? AddResource. ?????? ??? ???? ????? ???? ResourceWriter ?? ??? ??? ???? ???????? AddResource ??? ????? ??? ?????. ??????? ??????? ????? ????? ??? ?????? ??? ????? ??? ?? ??????? ??????? ????? ?????? ?????. ??? ??????? ??????? ????? ??? ?????? ?????? ?????, ??? ??? ??? ???????.

?????? ?? ?? ???? ????? ??????? ??? ??? ?????? ???? ??????? ???? ?? ??????? ??? ??? ??????.

??? ResourceManager ???? ????? ???????? ???????? ?????? ? ???? ???? ??????? ??? ???? ????? ??? ????? ??? ????? ????? ????? ???????? ??? ??? ??????. ???????? ??? ResourceManager ???? ?????? ?????? ??? ??????? ??????? ?????? ????? ???????? ????? GetObject ?????? GetString. ???? ???????? ?????? ??? ????? ?????? ??????? ??? ?????? ?????? ??????? ???????? ??????? ????? ??????? ???? ??? ????????.



???????


???? ??????? ??????? ??????? ?????? ??? ????? ?????? ???????? ?????? ? ??? ??????? ????????:
  • Microsoft Visual Studio .NET ?? Microsoft Visual Studio 2005
????? ??? ??????? ??? ??????? ??? ???????? ???????:
  • Microsoft Visual Basic .NET ?? Microsoft Visual Basic 2005
  • Microsoft Visual C# .NET ?? Microsoft Visual C# 2005

???? step-By-Step

  1. ??? ????? Visual Studio .NET 2002 ?? Visual Studio .NET 2003 ?? ?? Visual Studio 2005 .
  2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
  3. ???? ??? ?????? Visual Basic ??? ????? Project ?? ???? ??? ????? Windows ??? ?????.

    ?????? ?? Visual Studio 2005 ? ???? ??? Visual Basic ??? ????? Project.

    ?????????? ??? ????? ????? Form1.
  4. ?? ??????? ???? ???? ??? ???? ???????.
  5. ????? ???? ???? ?? ??? Form1.
  6. ?? ?????? "?????" ????? ?? ??????? ????? ???? ?? ??? ????? ??????.
  7. ???? ????? ??????? ??? ????? ???????.
  8. ????? ??????? ?????? ????? ??? ??? Form1.vb:
    Imports System.Resources
  9. ?? ?????? ????????? ???????? ??????? ?? ????? ??????? Button1_Click:
    ' Code to Create a Resource. 
    Dim objImage As Image
    Dim strString As String
    Dim rsw As ResourceWriter
    
    ' objImage is the Image that will be added as a resource.
    objImage = Image.FromFile("c:\\Winter.jpg")
    
    ' strString is the string that will be added as a resource.
    strString = "This is the string from resource"
    
    'Creates a resource writer instance to write to MyResource.resources.
    rsw = New ResourceWriter("MyResource.resources")
    
    'Adds the image to the resource.
    ' "MyImage" is the name that the Image is identified as in the resource.
    rsw.AddResource("MyImage", objImage)
    
    'Adds the string to the resource.
    ' "MyText" is the name that the string is identified as in the resource.
    rsw.AddResource("MyText", strString)
    
    rsw.Close()
    MessageBox.Show("Resource Is Created.....")
    ?????? ????? ???? Image.FromFile ("c:\\Winter.jpg") ???????? ??? ???? ?????? ???? ???? ????? ?????.
  10. ????? ???? ???? PictureBox ??? Form1.
  11. ????? ???? ???? ????? ??? Form1.
  12. ????? ???? ???? ?? ??? Form1.
  13. ?? ?????? "?????" ????? ??????? Text ????? ?????? Button2 ??? ??????? ??????.
  14. ???? ????? ??????? ??? ??????? ???????.
  15. ?? ?????? ????????? ???????? ??????? ?? ????? ??????? Button2_Click:
    ' Code to retrieve the information from the resource. 
    Dim myImage As Image
    Dim myString As String
    Dim rm As ResourceManager
    
    ' Create a Resource Manager instance.
    rm = ResourceManager.CreateFileBasedResourceManager("MyResource", ".", Nothing)
    
    ' Retrieve the Image from MyResource by using the GetObject method.
    myImage = rm.GetObject("MyImage")
    
    ' Retrieves the string from MyResource.
    myString = rm.GetObject("MyText")
    PictureBox1.Image = myImage
    Label1.Text = myString
  16. ?? ??????? ???? ???? ??? ??? ???? ???????.
  17. ?? ??????? ????? ? ???? ??? ???? ???? ?????? ???????.
  18. ??????? ????? ? ???? ??? "????" ?????? ???????.

???? ?? ???? ???

  1. ??? ????? "???????" ? ???? Form1.

    ???? ??? ????? ??????? ?????? ??? ????.

    ???? ???? ????? ????? ??? ?????? ?????.
  2. ???? ??? "??????? ???????".
  3. ???? ?? ?? ?????? ????? ??? ?? ??????? ?? ?????? ???? ?? ???????.

?????

????? ?? ?????????? ?? ?????? ????? ????? Network (MSDN) ?????? Microsoft ???????:
??? ResourceManager
http://msdn2.microsoft.com/en-us/library/system.resources.resourcemanager(vs.71).aspx
??????? ??????? ?? ??????? .Resources
http://msdn2.microsoft.com/en-us/library/khyt7e7y(vs.71).aspx
??????? ?? ???????
http://msdn2.microsoft.com/en-us/library/f45fce5x(vs.71).aspx

???????

???? ???????: 820659 - ????? ??? ??????: 27/???? ??????/1435 - ??????: 2.6
????? ???
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
????? ??????: 
kbnosurvey kbarchive kbmt kbvs2005applies kbvs2005swept kbstring kbresource kbbitmap kbhowtomaster KB820659 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????820659

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com