473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Reading File inuse by other process.

Hi
I am trying to read a file or get it's size while this file is written by
another process.
When i use the windows explorer i can read the file or check it's size .
When i use the FileInfo(size) it hangs until file is released.
Is there another way?

Thanks
Jun 28 '07 #1
2 1453
On Jun 28, 8:22 am, galsi <g...@discussions.microsoft.comwrote:
Hi
I am trying to read a file or get it's size while this file is written by
another process.
When i use the windows explorer i can read the file or check it's size .
When i use the FileInfo(size) it hangs until file is released.
Is there another way?

Thanks
When you attempt to open the file, make sure you are specifying the
appropriate sharing mode. Can you show some code that illustrates
your problem?

Chris

Jun 28 '07 #2
Thanks for quick respons here is the relevant code

int lastvalue =0;
string fPath = @"c:\temp\build.log";
FileInfo FI = new FileInfo(fPath);
while (1>0)
{
if (lastvalue - FI.Length == 0)
{
iCounter++;
lastvalue = FI.Length;
if (iCounter 20)
{
MessageBox.Show("times up");
break;
}

}
else
{
iCounter = 0;
}
lastvalue = FI.Length;
Thread.Sleep(SleepTime);
}
"Chris Dunaway" wrote:
On Jun 28, 8:22 am, galsi <g...@discussions.microsoft.comwrote:
Hi
I am trying to read a file or get it's size while this file is written by
another process.
When i use the windows explorer i can read the file or check it's size .
When i use the FileInfo(size) it hangs until file is released.
Is there another way?

Thanks

When you attempt to open the file, make sure you are specifying the
appropriate sharing mode. Can you show some code that illustrates
your problem?

Chris

Jun 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: muser | last post by:
With the following code I'm trying to read a text file (infile) and output inaccuracies to the error file (printerfile). The text file is written and stored on disk, while the printerfile has to be...
3
by: Steven Burn | last post by:
The application; Service on my webserver that allows a user to upload their HOSTS file for functions to verify the contents are still valid. Uses; 1. XMLHTTP (MSXML2) 2. FileSystemObject...
0
by: Eric Lilja | last post by:
Hello, I have a text file that contains a number of entries describing a recipe. Each entry consists of a number of strings. Here's an example file with only one entry (recipe): Name=Maple Quill...
3
by: trellow | last post by:
Hello, I am writing an application that needs to read a file that is already open by another process for writing. When I do the following: FileStream fs = new FileStream(fileName,...
8
by: Lonifasiko | last post by:
Hi, Using Process class I asynchronously launch an executable (black box executable) file from my Windows application. I mean asynchronously because I've got an EventHandler for "Exited" event....
3
by: cubaman | last post by:
Hello: Im workin with an app that checks for incoming files to a given folder using a FileSystemWatcher object. My problem is that if the file is too big, the Created event fires before the file...
6
by: Studlyami | last post by:
Is it possible to open a file for reading, while another process has it open for writing to it? One of the problems is that the process that is writing to it is written in C and is running on a...
4
by: sherifffruitfly | last post by:
Try to do something with it, and look at the exception? Some other way? Thanks!
9
by: tshad | last post by:
I am trying to get access to a file that may still being written because the file is so large (7-10MB). I get an error: The process cannot access the file 'c:\TestDocs\XMLFiles\492172.XML'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.