简体   繁体   English

将类序列化为Silverlight中的文件

[英]serializing class to file in silverlight

I have made a Silverlight app that contain a class and I want to serialize that class to some binaryfile of XML file , Is that possible in silverlight or not? 我已经制作了一个包含一个类的Silverlight应用程序,并且想要将该类序列化为XML文件的某个二进制文件,这在Silverlight中是否可行? without using WCF service,and how can i do it.? 不使用WCF服务,该怎么办?

You cannot write to files with Silverlight. 您无法使用Silverlight写入文件。 You cannot access the client filesystem for obvious security reasons. 出于明显的安全原因,您无法访问客户端文件系统。 If you need some storage on the client you could use the Isolated Storage . 如果需要在客户端上存储一些内容,则可以使用隔离存储 And for serializing a class to an XML string or a Stream you could use for example the XmlSerializer class. 为了将一个类序列化为XML字符串或Stream,可以使用例如XmlSerializer类。

Take a look at this video. 看一下这个视频。 It will help with how to access the local FS. 它将有助于如何访问本地FS。 I would assume the XML serializer is available for Silverlight but I am not certain. 我认为XML序列化器可用于Silverlight,但我不确定。

http://www.silverlight.net/learn/graphics/file-and-local-data/local-file-access For writing to isolatedstorage see this: http://programming4.us/multimedia/882.aspx http://www.silverlight.net/learn/graphics/file-and-local-data/local-file-access有关写入隔离存储的信息,请参见: http : //programming4.us/multimedia/882.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM