Silverlight browser Interaction: computing and expansion of independent storage space of Silverlight users

Source: Internet
Author: User

Overview

ISolatedstoragefile Member
An independent storage area that contains files and directories.

Isolatedstoragefile. getuserstoreforapplication Method
Obtain the User-Defined independent storage used by applications called from the VM domain.
An application in the domain (website) shares a group quota with all other applications in the domain.
This allows multiple applications in the same domain to share a quota. Note that the domain here refers to the virtual host domain (such as Microsoft.com), rather than the application domain.
The default independent storage size of the group quota is 1 MB. To increase the quota, use the increasequotato method.
To obtain the independent storage of all applications in the domain, use the getuserstoreforsite method.

Isolatedstoragefile. Quota attribute
Obtain a value that indicates the maximum amount of available space for independent storage.
This attribute gets the value from the associated quota Group of the storage area. The initial quota is 1 MB, which is shared by all applications in the domain.

Isolatedstoragefile. availablefreespace attribute
Obtain a value that indicates the amount of available space in the independent storage.
This attribute gets the value from the associated quota Group of the storage area. Because the quota may change, the value cannot be cached in the memory, but must be read from the disk directly each time.

Users can create files in an independent space, such as creating and reading files in a Silverlight user independent bucket.

Effect

Click expand space

After clicking yes, the space will change to 4 MB.

XAML code

<Grid X: Name = "layoutroot" background = "white">
<Canvas background = "white">
<Rectangle X: Name = "maximumrectangle"
Width = "1"
Height = "20"
Fill = "# ffffffff"
Stroke = "# ff000000"
Canvas. Left = "1"
Canvas. Top = "5"
Radiusx = "5"
Radiusy = "5"/>
<Rectangle X: Name = "currentrectangle"
Width = "1"
Height = "20"
Stroke = "# ff000000"
Canvas. Left = "1"
Canvas. Top = "5"
Radiusx = "5"
Radiusy = "5"
Strokethickness = "0">
<Rectangle. Fill>
<Lineargradientbrush endpoint = "0.5, 1.35"
Startpoint = "0.5,-0.3">
<Gradientstop color = "# ff54cdea"
Offset = "0"/>
<Gradientstop color = "# ff017328"
Offset = "0.5"/>
<Gradientstop color = "# ff54cdea"
Offset = "1"/>
</Lineargradientbrush>
</Rectangle. Fill>
</Rectangle>
</Canvas>
<Textblock margin = "30" X: Name = "TXT" Height = "20" verticalignment = "TOP"> </textblock>
& Lt; button width = "150"
Height = "30"
Content = "Extended Space"
Click = "button_click"/>
</GRID>

CS code

Public mainpage ()
{
Initializecomponent ();

// Set the rectangle size to indicate the size of the storage space
// Isolatedstoragefile Member
// Indicates an independent storage zone that contains files and directories.

// Isolatedstoragefile. getuserstoreforapplication Method
// Obtain the independent storage of the user range used by applications called from the VM domain.
// Share the group quota between an application in the domain (website) and all other applications in the domain.
// This allows multiple applications in the same domain to share a quota. Note that the domain here refers to the virtual host domain (such as Microsoft.com), rather than the application domain.
// The default independent storage size of the group quota is 1 MB. To increase the quota, use the increasequotato method.
// To obtain the independent storage of all applications in the domain, use the getuserstoreforsite method.

Using (VAR isofile = isolatedstoragefile. getuserstoreforapplication ())
{
// Isolatedstoragefile. Quota attribute
// Obtain a value that indicates the maximum available space of independent storage.
// This attribute is obtained from the associated quota Group of the bucket. The initial quota is 1 MB, which is shared by all applications in the domain.

// Isolatedstoragefile. availablefreespace attribute
// Obtain a value that indicates the amount of available space for independent storage.
// This attribute is obtained from the associated quota Group of the bucket. Because the quota may change, the value cannot be cached in the memory, but must be read from the disk directly each time.
Double usedspace = isofile. Quota-isofile. availablefreespace;
Maximumrectangle. width = (ISO file. Quota/10240) * 2;
Currentrectangle. width = (usedspace/10240) * 2;
TXT. Text = "the user's independent space is:" + usedspace + "kb ";
}

}

Private void button_click (Object sender, routedeventargs E)
{
Using (VAR isofile = isolatedstoragefile. getuserstoreforapplication ())
{
VaR newquotasize = isofile. Quota * 2;
VaR requestaccepted = isofile. increasequotato (newquotasize );
If (! Requestaccepted) return;
MessageBox. Show ("current space: \ n total space:" + isofile. Quota/(1024*1024) +
"M \ n available space:" + isofile. availablefreespace/(1024*1024) +
"M \ n independent storage space:" + isofile. usedsize/1024 + "M ");
}
}
}

Success !!!

Author:Memories of lost youth
Source: http://www.cnblogs.com/lukun/
The copyright of this article is shared by the author and the blog. You are welcome to repost this article. However, you must keep this statement without the author's consent and provide the original article connection clearly on the article page. If you have any questions, you can useHttp://www.cnblogs.com/lukun/Thank you very much for contacting me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.