Flush files

  • Thread starter Thread starter Peter Larsen []
  • Start date Start date
Hello Peter,

What did you mean "Flush" all opened files? When opening a file in .NET
framework with stream, we can call its Flush method to clears all buffers
for this stream and causes any buffered data to be written to the
underlying device. Did you want "flush" all files opened in a .NET
application? Based on my research, we need to "flush" the files one by one
since they use different Stream. For more information about File and Stream
I/O in .NET framework, you may refere to:

http://msdn2.microsoft.com/en-us/library/k3352a4t(VS.80).aspx

If there is any further questions, please feel free to let us know.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Luke,

Let me rephrase the question.

Is it possible to disable file cache on a local PC - by changing a registry
key or similar ?
I have read about some registry keys to control network cache, but no one to
control local cache.

The reason for i want this non-chache state is that i want to test file
access speed.

BR
Peter
 
Hello Peter,

When you open a file in .NET application, the cache is provided/controled
by .NET application, not the OS (So there is no a registry to disable
cache). Can you explain more on how you test the access speed in a .NET
application? Maybe we can find to avoid the impact of cache.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Luke,

I'm trying to measure how long time some specific steps, in an application,
consume.
It should be easy, but i can see that some disk write calls return before
they are written (it should take longer time).
Some of the files are beyond my control - i just call a function that
eventually may write to the disk. Thats why it would be nice if i just could
turn off local disk cache.

BR
Peter
 
Hi,

Thank you for the input. As I suggest before, we can use Flush method to
clears all buffers for this stream and causes any buffered data to be
written to the underlying device. (you need to execute it on each of file
you open with Steam). So, you also count the time for Flush method. Can
this help your test of the execution time?

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Luke,

Well, its true that we can use the flush function on each file, but if i
don't have access to the handle, Flush() won't be available.

In your first post, you say that file cache is handled internally by the
dotNet framework. Does this mean that the cache for files opened outside the
framwork is handled by the OS and the cache for files opened from inside the
framwork is handled by the framwork ??
But if that's true, how does the following tool work then ??

http://www.microsoft.com/technet/sysinternals/utilities/Sync.mspx

What i'm trying to say is that if the tool works for all files, then it
should be possible to something similar in code, right (?).

BR
Peter
 
You can use the StopWatch class to do benchmarking.

Dim sw as New StopWatch()
sw.start()
'place code to be benchmarked here
sw.Stop()
Console.WriteLine("Time elapsed: {0}", sw.Elapsed)

Robin S.
 
Hello Peter,

This utility (
http://www.microsoft.com/technet/sysinternals/utilities/Sync.mspx) handle
the cache for OS level:

http://support.microsoft.com/default.aspx/kb/837331

But it do nothing with .NET stream class. If you test is a .NET
application, the Flush method is still needed, and you also can call the
utility "sync" in the test application to ensure all has been flushed.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks Robin,
Thats what i do today. The problem is not to do the measurements, but to get
something useful from it.

BR
Peter
 
OK, i'v got the message - no single call in dotNet to flush all files opened
by the framwork.

Thanks.
Peter
 
Back
Top