|
Gary R. Wheeler wrote: The expense of the open/close is overwhelmed by the requirement to ensure as much data is secured as possible in the event of a catastrophic failure.
I agree on that, but if the stream has set AutoFlush to true this means that the data is written as soon as the Write operation is called, or am I wrong?
The console is a black place
|
|
|
|
|
In theory, yes. AutoFlush should "call" Flush immediately after every write. But... would I trust it for a critical log? Personally, no. I'd use File.AppendAllText or whatever to do the open-write-close anyway just to ensure that the log is closed between writes - so it can be backed up, copied, or examined without closing the application if nothing else.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Gotcha.
Now I still need to share the name of the logfiles between Writer and Rotator, and I'm tempted to do this with events. Or maybe a third FileWriteResources class? I'm brain-dead right now.
The console is a black place
|
|
|
|
|
I'd probably go with the third class which handles all actual file based stuff - unless performance is seriously going to be a problem in which case you want the minimum-time write solution and to heck with the rest being tidy!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: in which case you want the minimum-time write solution and to heck with the rest being tidy!
And there is my problem: I want / need both... I also thought about making the Rotator a singleton | static class which is triggered by the Writer (in certain time frames, e.g. once a minute or something like that). This would make it tidy and reasonably fast, since only the write but not the rotation time is critical.
The console is a black place
|
|
|
|
|
Marco Bertschi wrote: the data is written as soon as the Write operation is called
I'd be concerned about modern drive technology caching the writes regardless.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
I made the experience that AutoFlush does what it says, but will consider that.
The console is a black place
|
|
|
|
|
XmlDocument doc = new XmlDocument();
string place = String.Format("http://maps.googleapis.com/maps/api/geocode/xml?latlng=13.020164575569374,77.92610049247741&sensor=false");
doc.Load(place);
XmlNode element = doc.SelectSingleNode("//GeocodeResponse/status");
Am getting the XML document from google maps services. but am getting 403 forbidden error. While i copy the link and run in a browser then am getting that XML document which i need. I do have an api key , client ID or signature. I tried eveything in that link. But none worked out. Help me in solving it. thanks in advance.
|
|
|
|
|
Strange. Can you receive it with
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(place);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
etc.?
|
|
|
|
|
Thanks for your reply. I got that error because my proxy was restricting my web request. Now i have bypassed the proxy and got a readable address from latitude and longitude.
|
|
|
|
|
I need to clear a listbox from a class other than the form where it exists. Any idea why this isn't working? I'm getting no error messages when I compile and I am seeing the Console.WriteLine text I also added in the same function. I can call this function from within my form and it behaves as expected. I tried setting the listbox to public despite the fact I wasn't getting protection level errors but that made no difference.
Just to clarify what I'm doing here... I have a form that includes a panel of user controls from another class. So when I selected and item from otherListBox I want to clear the mainListBox in a MyForm. Heres my code:
MyForm
public void ClearMainListBox()
{
Console.WriteLine("echo");
mainListBox.Items.Clear();
}
OtherClass
private void otherListBox_SelectedIndexChanged(object sender, EventArgs e)
{
MyForm mf = new MyForm();
mf.ClearMainListBox();
}
|
|
|
|
|
Your program is behaving exactly as you should expect it to.
doby48 wrote: MyForm mf = new MyForm();
You create a brand new MyForm
doby48 wrote: mf.ClearMainListBox();
Clear the listbox
doby48 wrote: }
Then you let mf go out of scope and be destroyed.
If you really want your OtherClass to do anything with MyForm then you need to pass the existing instance of MyForm to OtherClass. Start with Transferring information between two forms, Part 1: Parent to Child[^]
|
|
|
|
|
I'm actually already doing the Constructor method listed on that page with a couple exceptions. I was mising the
InitializeComponent();<br /> in the child form and I was missing the mf.Show(); in the parent form. I added those couple commands though and still the same result.
|
|
|
|
|
Got it figured out. What I really needed to do was dispose the child form and recreate it which in turn clears the listbox in question. Thanks for the suggestion though.
|
|
|
|
|
hi every one,
I am a beginner programmer in c#.net(windows app) and I want to write a chat application has a database that clients can send offline messages.
what should i do?
modified 6-Jun-14 15:50pm.
|
|
|
|
|
Rather than ask a question in a forum why not do some research into your requirement, do a search of the articles and read through some of them, try Google. This type of application is often used as a teaching aid and there are lots of good examples.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
yes i search in google, but i couldn't find what i want.
|
|
|
|
|
Have some google foo[^]. If you can't get something out of that lot then you need to change your goals in life.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
thanks,i saw some of them before,but others were useful.
|
|
|
|
|
Please do not cross post. I answered your question.
How I Can Write A Chat Application?[^]
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
The question has been closed, not what I would consider and answer!
Still if the guy can't find a decent chat example on the interweb then I give up!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: The question has been closed, not what I would consider and answer! It was closed after I answered it actually.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
We can't provide the source code for big applications like that - We are all volunteers, and most of us have hobbies and interests apart from writing code and answering questions.
I did a little Google search for you, and feel like these two tutorials can help you coming closer to your goal:
TCP/IP Chat Application Using C#[^]
Basic Client-Server Chat Application[^]
The console is a black place
|
|
|
|
|
|
public void Download(string user,string filename, out byte[] file)
{
file = new byte[1];
if (!System.IO.Directory.Exists("Share"))
System.IO.Directory.CreateDirectory("Share");
foreach (string the in System.IO.Directory.GetFiles("Share"))
{
if(the.Contains(filename))
if (System.IO.File.Exists(the))
{
file = System.IO.File.ReadAllBytes(the);
AddLog(string.Format("> File: {0} has been downloaded at {1}. by {2}",(new System.IO.FileInfo(the)).Name,DateTime.Now.ToShortTimeString(),user));
break;
}
}
if (file.Length == 1)
file = null;
}
this is my code.
Anyone can help me convert it? Plzzzz.
|
|
|
|