gpt4 book ai didi

c# - 检查流是否为空

转载 作者:IT王子 更新时间:2023-10-29 04:47:51 25 4
gpt4 key购买 nike

我正在尝试反序列化一个 XML 文件。在绑定(bind)反序列化之前,我需要检查 XML 文件流是否为空。

IsolatedStorageFileStream isfs1 = new IsolatedStorageFileStream("test.xml", 
FileMode.Open, FileAccess.Read, isf);

// Deserialize the XML to an object
Settings s = new Settings();
SoapFormatter SF= new SoapFormatter();
s = (Settings) SF.Deserialize(isfs1);

如何检查 isfs1 是否为空?

最佳答案

检查 Length流的属性。

Length represents the number of bytes currently in the file.

如果为0,则文件为空。

关于c# - 检查流是否为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6179892/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com