|
Hello all,
I wana ask a simple question!
How a Stream object can be saved into the disk?!!
Thank u
---
"Art happens when you least expect it."
|
|
|
|
|
Hi,
Stream is an abstract base class. You could use it's deriative, the FileStream for easy writing to a file using the BinaryFormatter class.
HTH,
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
It greatly depends on what the stream is. More information would be helpful.
The snippet below - depending on whether or not the stream supports seeking - would work for many cases (but certainly not all, like with a NetworkStream - but not limited to it):
if (stream.CanSeek<)
{
stream.Seek(0, SeekOrigin.Begin);
using (FileStream file = new FileStream("file.dat", FileMode.Create,
FileAccess.Write, FileShare.Read))
{
int read = 0;
byte[] buffer = new byte[4096];
while ((read = stream.Read(buffer, 0, 4096)) > 0)
{
file.Write(buffer, 0, read);
}
file.Flush();
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I want to take a file as input and using PKZip or Win Zip extract it..All through C# code.
How to go about it??
|
|
|
|
|
|
Many Thanx....for solution.
|
|
|
|
|
|
I like this lib for doing zip/unzip.
http://icsharpcode.com/OpenSource/SharpZipLib/Default.aspx
Steve Maier, MCSD MCAD
|
|
|
|
|
|
Thanks Heath, sometimes posting from fireFox is just a pain, since I forget about the clickety.
Steve Maier, MCSD MCAD
|
|
|
|
|
I'm a student. My project group and I are doing a project - creating an appication for controlling stage lights. We code in C# and need to know more about DMX512 or where we can find info about it. We need to develop a dongle to communicate with the DMX devices. Help is needed urgently. Time is very limited! (Any info will be appreciated)
Thanx!
|
|
|
|
|
|
hi,
How can i know my dotnet application is not responding.
thanks
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
You can implement a "hearbeat" functionality:
An application is waiting for a hearbeat signal from your application and alarms if the heartbeat does not come after a certain time. Your application has then to create this heartbeat signal regularly (maybe in the working thread). The heartbeat signal can be a pipe or socket connection or something like that.
Hope that helps.
Greets
Roland
|
|
|
|
|
hi,
i am hearing this thing first time. How ? Where ? i start working on this new idea (for me)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Sorry, but i haven't any Code that I can give to you, but I try to explain you the mechanism a little bit more specific.
The idea is to have a TCP/IP Connection between the Application thats needed to be observed (lets call it "Application A") and the Application that will observe Application A and create an alarm (Application B).
One application should be an "server" (create a socket and start listening) while the other should be the "client" (create a socket and connect to the server). When the connection between the two applications is established, you can send periodically (ex. all 10 seconds) messages from Application A to Application B (ex. "alive"). When Application B does not get an "alive" message 20 seconds after the last "alive" message, Application B should create an alarm, stop and restart Application A or do something else.
If you haven't worked with sockets under C# have a look at the various articles here on codeproject.
Hope you will get with this information a step further.
Greets
Roland
|
|
|
|
|
here nothing like two application.
My doubt is how i will know once my application is under "Not responding mode". I have only one application
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
|
ha ha ..
So. Suppose if i am writing some service which will monitor my application status at regular interval.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
That was the idea my responses ... (The service will be "Application B")
Sorry for being not clear enough.
Greets
Roland
|
|
|
|
|
hi,
thanks a lot for your responce. And i will try my level best to do something.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
An application is marked as "not responding" if it's not processing windows messages for a given time.
This can occur because your main (GUI-)thread is performing a long-running action.
In that case you _can_ do something like monitor your application.
First step would be to fork out the possibly not responding functionality to a separate thread that can be monitored and aborted if it hasn't finished in a given time.
Regards,
mav
|
|
|
|
|
hi
mav.northwind wrote
An application is marked as "not responding" if it's not processing windows messages for a given time
What you mean by Marking ?
See i can't long running process. Cause it is pulrly depend on users who is using this s/w. If i want to mark then i need to mark all.
If i wrote some service then upto how much extend i will help me?
I am not at all good in service but still i can manage.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I meant the TaskManager showing an application as "not responding".
Or are you talking about a different sort of "not responding"?
|
|
|
|
|
hi,
Did you read the entire thred related to this heading ?
I will tell i want to know if my dotnet application is "not responding state". For that purpose what we can do is, we can write a paraell service which will monitor my application on a regular interval.
I am not that much good in Service. But still i can manage.
What is your idea ? Any better idea than this or can i go for a service. Is so which service i want to write.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|