MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FileStream.SetLength() Not Creating Empty Space

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> Compact Framework
Author Message
Charles Teel



Joined: 31 Jan 2008
Posts: 4

PostPosted: Sat Feb 09, 2008 2:26 pm    Post subject: FileStream.SetLength() Not Creating Empty Space Reply with quote

I've noticed that whenever I use FileStream.SetLength() on a file that
is on the emulator, the file is empty (filed with nothing but zeros).
But whenever I use it on an actual device it is not empty. In some
cases its filled with data that was stored in files that had since
been deleted.

Is there a way to SetLength() a file and have the new space be filled
with zeros other than going in an actuall writing a bunch of zeros?
The key thing I need is speed.

Archived from group: microsoft>public>dotnet>framework>compactframework
Back to top
View user's profile Send private message
user



Joined: 08 Aug 2007
Posts: 286

PostPosted: Sat Feb 09, 2008 5:10 pm    Post subject: Re: FileStream.SetLength() Not Creating Empty Space Reply with quote

The behavior you see is likely the way the devices file system driver works.
If it initialized to all zeros that would actually be slower because it
would have to go in and write zeros for you, so what you see now is actually
faster. If you want it to be cleared, you'll have to manually go in and
write zeros. I suspect the most efficient mechanism to do that is to create
an empty byte array and copy that to the stream - probably in 4k chunks
(since that's a page size).


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


"Charles Teel" wrote in message @z17g2000hsg.googlegroups.com...
> I've noticed that whenever I use FileStream.SetLength() on a file that
> is on the emulator, the file is empty (filed with nothing but zeros).
> But whenever I use it on an actual device it is not empty. In some
> cases its filled with data that was stored in files that had since
> been deleted.
>
> Is there a way to SetLength() a file and have the new space be filled
> with zeros other than going in an actuall writing a bunch of zeros?
> The key thing I need is speed.

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Creating new dataview Does all dataview's in .net compact framework have to be created via code or is there a way in Visual Studio IDE to create them and just reference then in VB code?

Creating Cabinet Files I seem to be hitting a problem when I try to create a cabinet file for an Application that deploys and runs normally. Unfortunately the error I am getting seems a little obscure: "C:\Program Visual Studio

Not enough disk space???? Standard Windows forms app. Standard setup project creating a standard msi. Run that on a target computer and I get.... "The amount of required disk space exceeds the amount of available disk space. Disk size: 18 GB. Available: 14 GB. Required: 716 KB.

Invalid Name Space when calling ManagementObjectSearcher.Get I have the following code to try to find mmui.exe that may be running under this user. This code works on all of our machines. However, on one machine it says Invalid Name Space at at

Empty datasets in N-Tier App Hi all, FYI: I'm pretty much a novice coming over from AccessXP. After watching the Webcast about buiding N-Tier applications I created an SQL database and built the application as was shown by Paul Sherriff. The only problem I seem to be having at the mo
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> Compact Framework All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group