|
hi
i have problem with end of process.
i need to zip file - and after i zip - i need to do some thing with this zip file...
the problem is, although the messagebox appear - i noticed that the process is not end.
how i can know for sure that the process is end ?
my zip sample:
try{
if (File.Exists(@"c:\DaZIP\Bind.sdf"))
File.Delete(@"c:\DaZIP\Bind.sdf");
File.Copy(Application.StartupPath + @"\Bind.sdf", @"c:\DaZIP\Bind.sdf");
byte[] sampleBuffer = null;
ZipEntry sampleZipFile = null;
FileStream sampleFileStream = null;
ZipOutputStream sampleOutputStream = new ZipOutputStream(File.Create(Application.StartupPath + @"\Bind.zip"));
sampleOutputStream.Password = "12345";
sampleOutputStream.SetLevel(9);
foreach (string sampleFile in Directory.GetFiles(@"c:\DaZIP")) {
sampleZipFile = new ZipEntry(Path.GetFileName(sampleFile));
sampleOutputStream.PutNextEntry(sampleZipFile);
sampleFileStream = File.OpenRead(sampleFile);
sampleBuffer = new byte[sampleFileStream.Length];
sampleFileStream.Read(sampleBuffer, 0, sampleBuffer.Length);
sampleOutputStream.Write(sampleBuffer, 0, sampleBuffer.Length);
}
sampleOutputStream.Finish();
sampleOutputStream.Close();
}
catch (Exception ex){ MessageBox.Show(ex.Message ,"",0, MessageBoxIcon.Exclamation);
return;}
MessageBox.Show("End ZIP");
i work on VS2008 C# WinForm
i know that the process still work, because when i try to do somthing with the zip
file, i get error that the file is in use. and if i wait for 1-2 minute, i can do what i
want with this zip file.
|
|
|
|
|
E_Gold wrote: i know that the process still work, because when i try to do somthing with the zip file, i get error that the file is in use
That may well be a wrong conclusion. The one way to know whether a process is (still) running or not, is by looking at the Task Manager's list.
Here is what is probably going on:
if you want write or delete access (anything other than read access) to a file that just got created (by yourself or someone else, does not matter), chances are you will find the file is being accessed by some other process, and your access is not granted.
The other process very likely is some server code that is there to assist you somehow. Candidates are:
- anti-virus software (Norton, McAfee, whatever)
- indexing software (Google Desktop, MS Office, whatever)
The common thing is these packages are looking all the time for new files, so they can inspect them.
Microsoft is aware of the consequences; Windows Explorer will try rename and delete attempts up to five times (with one-second interval), and only reports failure if the action continues to fail for that time.
The solution:
1. either use a different file name (not always acceptable)
2. or remove all background reader candidates (bad idea)
3. or implement the retry loop as Explorer has it (use a Windows.Forms.Timer for this)
BTW: if all you need is Read, make sure to allow others to read as well, i.e.
use File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)
Remark: in my experience, trying to open/append/close a file more often than once a second succeeds all the time, seems like the inspectors allow for at least one second of inactivity before opening the files themselves.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hey everyone,
I'm looking for a way to either hook my C# application to a instant messenger (like msn) or make a full C3 instant messenger application with which I can talk with a friend of mine that I will give the same application.
Basicly I'm trying to make me a own chat enviroment but I want it to be save against hackers (no needless open ports) and it has to be not lan since my friend lives about 40 km away from me
Any help will be usefull.
ps. So far i have not yet found anything that can tell me if C# can execute events on MSN receieved messages and/or C# can send messages via msn. Have not looked in to other messengers (like aim or icq.. or whatever)
|
|
|
|
|
Hey again everyone,
I found out it's easy to use a mircbot as between me and my friend for communication
Cheers
|
|
|
|
|
Hello,
I need to develop one application say, if i speak "run notepad", notepad should be opened.
For that i have use following code to implement speech recognition,
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
DictationGrammar gram = new DictationGrammar();
recognizer.LoadGrammar(gram);
recognizer.SetInputToDefaultAudioDevice();
recognizer.RecognizeAsync(RecognizeMode.Multiple);
void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show(e.Result.Text);
}
I don't know how to add grammer, please help me out.
Thank you in advance.
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:18am.
|
|
|
|
|
Hello,
Thank you for reply.
But i don't understand that msdn dictationgrammer(), so please tell me in details what should i do.
And if i write in vista will it be work in xp too?
Please help me.
Thank you.
|
|
|
|
|
Im looking for info on how to create bots that interact with with the screen.
I want to create bots that "sees" the screen and interacts with it in a way that i program.
For example a flash game of tic tac toe or chess, or a normal webpage
I not so much in need of games solving algorithms at the moment...at the moment i need information on how i make the bot retrieve/interpret/interact with the screen.
|
|
|
|
|
Dear Merger,
Well, you could do this in a few different ways depending on what you want to interact with. You could pole for positions of windows to see if they have moved, you can use directx or XNA (I suppose) to track the mouse's position, clicks and keyboard events...If you're wanting a way to collectively get information about the screen all in one swoop (the visual information in the screen, window positions, titles, mouse position, clicks, keyboard events, etc), I don't suppose that's possible: you have to do it all independently. If you want a bitmap of the screen (like obtained by pressing `print screen') I'm sure that's very easy...let me do a quick Googler...yup, there it is:
Graphics.CopyFromScreen(...));
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.copyfromscreen.aspx[^]
So, if you could be WAY more specific, you will get more responses.
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
Thanks for your reply...here is a little more information to clarify.
Im not sure what i wanna do quite yet I can see alot of possibilities though.
But for an example:
An online chessgame. I want to enable my program to play automatically.
For that to be possible i see a few problems that needs to be solved.
1. The program must gather the information from the screen, that should be quite easy to do with the method you posted above.
2. The program needs to analyze the information on the screen. In this example it needs to recognize the chessboard, the chesspieces and probably something else.
3. The program needs to calculate the best move.
4. The program need to interact with the chess program.
1,3 and 4 i think i know how to handle. But i dont know how to handle the second problem.
So what im asking about is probably links or information on how to interpet the information of the screen (bitmap)
kind regards,
Anders
|
|
|
|
|
Dear Mr. Anders,
I see what you're talking about now, you're wanting your bot to interact with the Internet. This does seem VERY difficult. My approach (but I have no idea how to do what you're doing) would be to create a program for each scenario. For instance, using Chess, at GameKnot, you know how their board looks, and how the source code for those boards look, so you could have your program get the source code for the current page (the chess game you're playing currently, although this IS cheating acccording to Gameknot regulations, so don't do it there), then calculate the best move, then to put in its move, it would perhaps have to simulate clicks based on where it thinks the squares are. The other option is to see what the code for a click is in the webpage, and somehow make the webpage think you clicked on the desired square...I'm really clueless. Good luck!!
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
This is exactly what i want to do. But it dont have to be a chessgame, that was just an example.
The problem i face at the moment is that i dont know where to start. Sure i can get a screenshot of the chessboard, but then what? How do code something that recognizes the board and chesspieces?
Im assuming that it would be very error prone and ineffective to compare every pixel with presaved images (of the chesspices) and try to make my "virtual" chessbord that the computer understand.
So...if anyone know how to interpet images and translate them to something that the computer understand and can calculate i would be very grateful. Link, examples, anything is of interest
Kind regards,
Anders
|
|
|
|
|
Hey guys I have a problem in retriving the cell data from the gridview...Though I had tried with selected index change and row commands........the value it gives is just null...........here is the code
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int row_index = int.Parse(e.CommandArgument.ToString());//gives index of the row
string _commandName = e.CommandName;
Label1.Text = Info_DGV.Rows[row_index].Cells[1].Text.ToString();
}
|
|
|
|
|
hi everyone,i'm a beginner,this is my question;
make DATA show on treeview Automatically
for exeample
Field "class1" and "class2" is in Database "STUDENT"
a、b、c、d,four students are Belong to class1
e、f、g、h,four students are Belong to class2
class1 and class2 as father node
8 students as son node of each father node
how could it show on treeview Automatically?
and when click every student it will Trigger some Matter
please show me the code
Grateful for everyone!
|
|
|
|
|
Hi,
this is not a "show me some code" site, this is a site where people who got stuck at a specific point show the relevant part of their code and then get help.
Seems like your problem needs to fetch and iterate over all students, and add nodes such as class1/student1 and class2/student5 to the TV. Basically it is similar to this example[^], however it is simpler in that there are only two levels involved.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Open up your Visual Studio and try something. If you get stuck up somewhere, then come back and ask for help. We would be happy to help you then
|
|
|
|
|
|
Hi everyone, I have a problem. Some of my code only works when debugging with breakpoint on it. Anyone knows the reason?
By the way I'm newbie in this area so maybe I made stupid little error.
private void timer1_Tick(object sender, EventArgs e)
{
if (tcpListener.Pending() == true)
{
hostSocket = tcpListener.AcceptSocket();
if(hostSocket.Poll(1, SelectMode.SelectRead))
{
int numBytes = hostSocket.Available;
Byte[] data = new Byte[numBytes];
hostSocket.Receive(data);
timer1.Stop();
string msg = System.Text.ASCIIEncoding.ASCII.GetString(data);
string[] co = msg.Split(' ');
Console.WriteLine(msg);
}
}
}
modified on Monday, November 9, 2009 5:53 AM
|
|
|
|
|
Hi,because you've put the data receiving code in the 'if(tcpListener.Pending()){} statement this only works when you put a breakpoint on it. That is because only then the client has the time to send data before the next time the timer fires an event and the tcpListener.Pending() returns false.
This should solve it:
if (tcpListener.Pending() == true)
{
hostSocket = tcpListener.AcceptSocket();
}
else if (hostSocket != null)
{
if (hostSocket.Available != 0)
{
int numBytes = hostSocket.Available;
Byte[] data = new Byte[numBytes];
hostSocket.Receive(data);
string msg = System.Text.ASCIIEncoding.ASCII.GetString(data);
string[] co = msg.Split(' '); Console.WriteLine(msg);
timer1.Stop();
}
}
Regards
|
|
|
|
|
Thanks, Jorgdedecker.
It works like a charm
|
|
|
|
|
When I double click an *.xsd file in Visual Studio 2008 I only got the markup code. When I rightclick and choose “View Designer” I only got a blank page. I’ve tried to repair the installation and installed SP1. Any tip what can be done?
_____________________________
...and justice for all
|
|
|
|
|
Hi Team,
I have a functional requirement in C#.net to develope a plug-ins and implement in outlook.
Could any body help me out from this scenario from high level or code level context.
Thanks in Advance.
Regards
Tarun Singh
Sr. Software Engineer.
mailto:tksingh@zenta.com
|
|
|
|
|
codeproject_Tarun wrote: I have a functional requirement in C#.net to develope a plug-ins and implement in outlook.
This[^] was not too difficult.
|
|
|
|
|
could you provide the way of technical approach toward achieve this.
Regards
Tarun Singh
Sr. Software Engineer.
mailto:tksingh@zenta.com
|
|
|
|
|
codeproject_Tarun wrote: could you provide the way of technical approach toward achieve this.
Well I gave you a link to a number of examples showing what you asked for, so I don't know what more you expect.
|
|
|
|
|