|
I’m using Visual Studio 2010 on Windows 7
I’m trying to write a log file in one program while reading the same log file in a second program.
The first program receives data from a server every minute from second 0 through second 5.
I want the second program to sleep till 30 seconds after each minute, read the traces from the first program’s log file, and display any warnings.
I found a post on the web saying I should open the file in program 1 as:
_logStream = new FileStream(logFileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
_logFile = new StreamWriter(_logStream);
Then open the file in program 2 as:
var _logStream = new FileStream(filename1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var xyz = new StreamReader(_logStream);
But I get the error message:
Unhandled Exception: System.IO.IOException: The process cannot access the file '
C:\SandBox\120405133716.log' because it is being used by another process.
Can this be done in Window's 7 ??
If so, what is the proper code ??
|
|
|
|
|
I don't like textfiles as a buffer. I'd switch to a database, and do insert's and selects - that would also solve the problem of simultaneous access.
Bastard Programmer from Hell
|
|
|
|
|
|
No. The only code you're going to get is the code you write.
We're not in the business of handing projects out to everyone who demands them. We're in the business of helping you with your own code.
|
|
|
|
|
Dave Kreskowiak wrote: No. The only code you're going to get is the code you write.
Perhaps Chris should rename the site, The Codes Project.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
or perhaps the CODEZZZ URGNNTZZZ!!!! PROJECT
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Quote: codes for the note pad
Is that supposed to mean something?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
1. Press the windows key + R.
2. In the dialog that appeared, type in the code "notepad" (without quotes)
Notepad launches.
V.
|
|
|
|
|
Notepad is basically a TextBox. Create a form, add a TextBox and menu items to load/save text, and you essentially have NotePad.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Hi
I have application that is define as MDI,
there are several form child
once the user press X button, i wish the application to be close and all other windows.
at the FromClosing event i add the following code
//handle and close the logic layer...
foreach (Form frm in this.MdiChildren)
{
frm.Close();
frm.Dispose();
}
Application.Exit();
All childs are closed but the the event FromClosing
happen agian, why?
i would expect the event of the main form FromClosing will happen only one time.
this cause my problems at the logic layer
ronen
|
|
|
|
|
Ronenb wrote: All childs are closed but the the event FromClosing
happen agian, why?
Because you called "Application.Exit", which will close all the forms and exit the application. You needn't close all forms manually, exiting the application should be enough and should close all remaining forms (and dispose them) automagically.
Bastard Programmer from Hell
|
|
|
|
|
in case i will remove closing the child manully, once i click close "X", each time child window will be closed
i need to press X button accurding the number of child windows that are opend
what am i'm missing?
what is the correct process to close MDI application?
thanks
ronen
|
|
|
|
|
There are TWO X-es on a MDI-form if you have the children maximized. If you want to close the application, you close the mainform. That's how things work in Windows, and across all other MDI-applications. If you close one of the child-windows by using it's X, then you are merely closing that particular document of the "Multiple Document Interface".
Likewise, Ctrl-F4 would close a child-document, Alt-F4 would close the application.
Ronenb wrote: what is the correct process to close MDI application?
Application.Exit from code, the X topright of the mainform or Alt-F4 from user-input.
Bastard Programmer from Hell
|
|
|
|
|
i'm trying to closing the app by the mainform X , not the child form X
the status is when i press the mainform X, a child win is closed, each click close child form till all childs are closed, last click on X close the app once no child exist
any advice?
|
|
|
|
|
Ronenb wrote: any advice?
Yes. Post the code from the children's OnCloseForm handler.
Start a new project, add this code;
namespace WindowsFormsApplication15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.IsMdiContainer = true;
new Form() { MdiParent = this, Visible = true };
new Form() { MdiParent = this, Visible = true };
}
}
} That'll display two documents within a MDI-parent. App will close on X, unless you have some custom code somewhere.
Bastard Programmer from Hell
|
|
|
|
|
Do any of the child forms have FormClosing(..) handlers? If so check them to see if they might be doing anything that's interfering, such as setting e.Cancel to true.
You might also try stepping through the main form's closing handler with the debugger if you haven't done that already.
BDF
I often make very large prints from unexposed film, and every one of them turns out to be a picture of myself as I once dreamed I would be.
-- BillWoodruff
|
|
|
|
|
i am using three tables and i want ot bind that tables to the treeview control so please suggest me with an example
|
|
|
|
|
WPF? Silverlight? ASP.NET? Windows Forms?
The technique you will use depends on the technology you are using.
|
|
|
|
|
Hi.
I want source code for image encryption (and decryption) in C# language (with chaos signals), please help me, it's my project.
thanks.
|
|
|
|
|
If we give you the source code, it's not really your project is it? It's someone else's project at that point. Are you willing to give them whatever award you are trying for here?
|
|
|
|
|
no it's in my university.
I'm interesting
do u have source code ?
|
|
|
|
|
Danial C wrote: do u have source code ?
I do.
Am I going to give it to you? No.
Why? Because that would be helping you to cheat. If you can't do this task on your own, why should we help you to cheat? Note the use of the word "cheat" here.
|
|
|
|
|
I want just you help me, I want to learn about this. cheat ? no, i'm not who you think.
however thanks.
|
|
|
|
|
There are tons of articles out on the web, most wih code samples! All you have to do is Google "steganography".
This is for a univeristy project? Didn't they teach you how to do research, oh, back in high school? You better learn very fast because that skill is what is going to keep you in a job.
|
|
|
|
|
im using microsoft visual c# express and its database.
through my c# program i wanted to retrieve a folder path from the database to select files.but im getting this error.please help.
i have created a column 'folder_path nvarchar(50)'
my folder path is : @"f:/pick_up"
if i put folder path as 'comp' it reads.i guess the error has something to do with special characters @,/ and ".
reply asap.thank you.
|
|
|
|