Click here to Skip to main content
15,917,062 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: The process cannot access the file because it is being used by another process Pin
Pedram Behroozi3-Oct-08 9:27
Pedram Behroozi3-Oct-08 9:27 
QuestionAdd Project References at runtime Pin
AngusOAP3-Oct-08 5:16
AngusOAP3-Oct-08 5:16 
AnswerRe: Add Project References at runtime Pin
dan!sh 3-Oct-08 5:26
professional dan!sh 3-Oct-08 5:26 
AnswerRe: Add Project References at runtime Pin
led mike3-Oct-08 5:46
led mike3-Oct-08 5:46 
GeneralRe: Add Project References at runtime Pin
AngusOAP4-Oct-08 2:13
AngusOAP4-Oct-08 2:13 
GeneralRe: Add Project References at runtime Pin
led mike6-Oct-08 4:48
led mike6-Oct-08 4:48 
AnswerRe: Add Project References at runtime Pin
Paul Conrad3-Oct-08 6:35
professionalPaul Conrad3-Oct-08 6:35 
QuestionCommunicating with user controls Pin
KabirPatel3-Oct-08 4:38
KabirPatel3-Oct-08 4:38 
AnswerRe: Communicating with user controls Pin
Pedram Behroozi3-Oct-08 5:00
Pedram Behroozi3-Oct-08 5:00 
QuestionRe: Communicating with user controls Pin
nelsonpaixao3-Oct-08 13:13
nelsonpaixao3-Oct-08 13:13 
Questionexcel cell alignment Pin
michael_jhons3-Oct-08 4:04
michael_jhons3-Oct-08 4:04 

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.