|
You can't just append the character to the text?
|
|
|
|
|
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
|
|
|
|
|
Alan Balkany wrote: The process cannot access the file because it is being used by another process.
Maybe this "another process" is you! Always make sure you closed all opened files in your project.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
But the file is never explicitly opened. It's hard to close a file that was never opened.
|
|
|
|
|
Maybe you have some problem with Vs and/or Windows or even vise versa!
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Hey, you didn't close your file!
<blockquote class="FQ"><div class="FQA">Alan Balkany wrote:</div>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);
}
}</blockquote>
Add fi.Close(); before fi = null;
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Your Bitmap object keeps the file open.
Try disposing the Bitmap object after you're done working with it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes! You solved it! I just copied the bitmap to a new one and disposed the old one, and it worked! Thanks Mark!
|
|
|
|
|
Oh, you're right. My mistake! Thanks Mark
While (true) { Human.isLearnable = true; }
|
|
|
|
|
I have a C# application which creates Excel Workbooks. To date I have added reference to the Excel version installed on my machine. I now need to do something which will read the Excel version installed on a user's machine and call the appropriate library.
Does anybody know how to do this? Many thanks
Angus
|
|
|
|
|
Use Type.GetTypeFromProgID and Activator.CreateInstance to instantiate the object. Then you can use Reflection for further operations.
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
|
|
|
|
|
AngusOAP wrote: I now need to do something which will read the Excel version installed on a user's machine and call the appropriate library.
Loading an assembly at runtime is not the same thing as adding a reference to a project.
If you are using the Primary Interop Assembly there is no guarantee that the users machine has it installed. You might be needing to study the Microsoft information[^] about using the Primary Interop Assemblies.
led mike
|
|
|
|
|
Thanks, but having read the Microsoft information I fear I may be debarred - it says that I have to have Microsoft Visual Studio .NET for developers, whereas all I have is the miserablt C# Express Edition (2005 version plus Service Pack 1, at that). Do you know if it is it worth trying with that?
Thanks again.
Angus
|
|
|
|
|
AngusOAP wrote: Do you know if it is it worth trying with that?
I've never used Express Edition. However the PIA's are just assemblies so I would guess there should be no problem.
led mike
|
|
|
|
|
Like led mike said, read up from Microsoft on how to work with the PIA.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi,
I have a windows form that contains 2 buttons - a "Next" button and a "Prev" button.
When the form loads, a user control is loaded into the form. After the user presses the "Next" button, the user control is replaced by another user control. If the user presses the "Prev" button they move back to the prevous control. The process continues like this until 5 different user controls are loaded. i.e. I have implemented Wizard like functionaility.
This all works fine.
My problem is that the "Next" and "Prev" buttons are always enabled. I would only like the "Next" button to be enabled if the user has completed working on the User Control that they are currently on.
In other words, once a user has completed the minimum requirements of the control they are in, the "Next" button should become enabled.
An example of this would be a user control with a first name field. When the user fills in this field the "Next" button should be enabled.
Is it possible for the user control to bubble up this information back to its parent form, so that the button is enabled at the proper time?
Thanks,
Kabir
|
|
|
|
|
Hi Kabir
You can use a public bool variable (true/false) in your UC. When user fills a valid text, your flag goes true, else false. And your form can use your flag to complete your task.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
if you are using delegates i don´t see how you didn´t achieve that after what you already coded?!
parent form? you meen main_form and only form right? because you load usercontrols in main_form? i don´t see where is the change
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
hello everybody
can somebody help me in formating excel cells inside a worksheet:
i tried
worksheet.get_Range(worksheet.Cells[2, 1], worksheet.Cells[2, 3]).HorizontalAlignment = HorizontalAlignment.Left;
but gave me an error i made a research i found that i have to use
... HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
the problem is that i couldn't find XlHAlign property i tried many reference but without any solution.
thank you in advance and kind regards
|
|
|
|
|
michael_jhons wrote: but gave me an error i made a research i found that i have to use
... HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
But it worked for me!
It's my code:
using System;
using System.Text;
using Microsoft.Office.Interop.Excel;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
WorksheetClass ws = new WorksheetClass();
ws.get_Range(ws.Cells[2, 1], ws.Cells[2, 3]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
}
}
}
While (true) { Human.isLearnable = true; }
|
|
|
|
|
thank you pedram, it was the
using Microsoft.Office.Interop.Excel; i added as a reference but when i added from using XLHalign apears, thank you fro your help
|
|
|
|
|
Range rng = objSheet.getRange(col1, row1,col2 ,row2);
rng.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
enjoy it
soicodon : mihazu_undead@yahoo.com
|
|
|
|
|
Am I correct in thinking that the only difference is:
ref has to be preassigned but does not have to be used in the method
out must be assigned before returning but can be unassigned before calling the method
?
Are there any notable benifits of using either one?
[edit] Just discovered that if using out, the parameter is treated as if it is unassigned (even if it's already been assigned) as soon as you call the method. So it appears that ref is kind of an input and output parameter whereas out is just output.[/edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
modified on Friday, October 3, 2008 7:37 AM
|
|
|
|
|
|
Brij wrote: for 'ref' it doesn't need to assigned by callee
Yes it does.
Read the page that you linked to.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|