Click here to Skip to main content
15,928,281 members
Home / Discussions / C#
   

C#

 
AnswerRe: compare 2 datetime and get hours Pin
J4amieC3-Oct-08 9:56
J4amieC3-Oct-08 9:56 
AnswerRe: compare 2 datetime and get hours Pin
J$3-Oct-08 9:59
J$3-Oct-08 9:59 
QuestionPut sound on own simple program Pin
MorganSim3-Oct-08 8:46
MorganSim3-Oct-08 8:46 
AnswerRe: Put sound on own simple program Pin
DaveyM693-Oct-08 9:04
professionalDaveyM693-Oct-08 9:04 
QuestionRe: Put sound on own simple program Pin
MorganSim3-Oct-08 10:22
MorganSim3-Oct-08 10:22 
AnswerRe: Put sound on own simple program Pin
Dan Neely3-Oct-08 10:32
Dan Neely3-Oct-08 10:32 
AnswerRe: Put sound on own simple program Pin
DaveyM693-Oct-08 10:58
professionalDaveyM693-Oct-08 10:58 
AnswerRe: Put sound on own simple program Pin
PIEBALDconsult3-Oct-08 9:37
mvePIEBALDconsult3-Oct-08 9:37 
QuestionRe: Put sound on own simple program Pin
MorganSim3-Oct-08 9:51
MorganSim3-Oct-08 9:51 
AnswerRe: Put sound on own simple program Pin
PIEBALDconsult3-Oct-08 10:23
mvePIEBALDconsult3-Oct-08 10:23 
QuestionPass Dataset table to a stored procedure as a parameter Pin
Litani3-Oct-08 8:46
Litani3-Oct-08 8:46 
GeneralRe: Pass Dataset table to a stored procedure as a parameter Pin
nelsonpaixao3-Oct-08 14:20
nelsonpaixao3-Oct-08 14:20 
QuestionProgammatically pressing underscore,$,% etc keys Pin
Sandeep Kalra3-Oct-08 7:43
Sandeep Kalra3-Oct-08 7:43 
AnswerRe: Progammatically pressing underscore,$,% etc keys Pin
Sandeep Kalra3-Oct-08 8:08
Sandeep Kalra3-Oct-08 8:08 
AnswerRe: Progammatically pressing underscore,$,% etc keys Pin
led mike3-Oct-08 8:49
led mike3-Oct-08 8:49 
GeneralRe: Progammatically pressing underscore,$,% etc keys Pin
Sandeep Kalra3-Oct-08 9:01
Sandeep Kalra3-Oct-08 9:01 
RantRe: Progammatically pressing underscore,$,% etc keys Pin
Jason Lepack (LeppyR64)3-Oct-08 9:02
Jason Lepack (LeppyR64)3-Oct-08 9:02 
AnswerRe: Progammatically pressing underscore,$,% etc keys Pin
PIEBALDconsult3-Oct-08 10:32
mvePIEBALDconsult3-Oct-08 10:32 
QuestionThe process cannot access the file because it is being used by another process Pin
Alan Balkany3-Oct-08 6:51
Alan Balkany3-Oct-08 6:51 
Hi all,

I'm testing an application by writing bitmaps to a temporary file. I thought it would be neat to have an application that monitors this file and updates its picture whenever the file changes.

I use FileInfo to get the last write time, and if it's changed, I make a new Bitmap with the file's contents and display it. The file is never opened. Sounds simple.

The problem is the system thinks the file is in use, and won't let me overwrite it. It says: "The process cannot access the file because it is being used by another process." But I never open the file, and just use it temporarily to get the last write time and make a bitmap.

How can I make Windows realize the file isn't being used in between samples?

Here's the relevant code:

public void monitorFile()
 {
     while (!Form1.done)
     {
         fi = new FileInfo(fname);
         DateTime dt = fi.LastWriteTime;

         if (lastWrite < dt)
         {
             lastWrite = dt;
             parent.showBitmap (new Bitmap(fname));
         }

         fi = null;
         Thread.Sleep(3000);
     }
 }

Thanks!
Alan
AnswerRe: The process cannot access the file because it is being used by another process Pin
Pedram Behroozi3-Oct-08 6:59
Pedram Behroozi3-Oct-08 6:59 
GeneralRe: The process cannot access the file because it is being used by another process Pin
Alan Balkany3-Oct-08 7:01
Alan Balkany3-Oct-08 7:01 
JokeRe: The process cannot access the file because it is being used by another process Pin
Pedram Behroozi3-Oct-08 7:13
Pedram Behroozi3-Oct-08 7:13 
AnswerRe: The process cannot access the file because it is being used by another process Pin
Pedram Behroozi3-Oct-08 7:22
Pedram Behroozi3-Oct-08 7:22 
AnswerRe: The process cannot access the file because it is being used by another process Pin
Mark Salsbery3-Oct-08 7:36
Mark Salsbery3-Oct-08 7:36 
GeneralRe: The process cannot access the file because it is being used by another process Pin
Alan Balkany3-Oct-08 7:52
Alan Balkany3-Oct-08 7:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.