Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

Reading File inuse by other process.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
galsi - 28 Jun 2007 14:22 GMT
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
Chris Dunaway - 28 Jun 2007 14:37 GMT
> Hi
> I am trying to read a file or get it's size while this file is written by
[quoted text clipped - 4 lines]
>
> 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
galsi - 28 Jun 2007 15:08 GMT
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);
           }

> > Hi
> > I am trying to read a file or get it's size while this file is written by
[quoted text clipped - 10 lines]
>
> Chris

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.