|
AFAIK there's nothing that lets you determine whether the file is ready to move. So you'll have to try and in case some exception is thrown it obviously wasn't ready.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
hello,
I wana show the cards in randomly from the array when I click the start button. ex: I have 12 picture boxes. and if click the button , the randomize cards come out to those boxes. How should I do ? pls help..this out
|
|
|
|
|
You could use System.Random[^] to generate the random numbers. The Next[^] method has an overload that allows you to specify the maximum value (12, in your case). You could generate 12 random numbers in that range and use them to shuffle the elements in the array.
class CardShuffler
{
Random randomGen = new Random();
Card []cards = new Card[12];
public void Shuffle()
{
for (int i = 0; i<cards.Length; ++i)
{
int newIndex = randomGen.NextInt(i, 12);
Card temp = cards[newIndex];
cards[newIndex] = cards[i];
cards[i] = temp;
}
}
}
|
|
|
|
|
|
hey,
is there anybody can give hints for my game? I ll to appear the cards in Randomly on the specific boxes when I click one button! And the game is to match three same cards by rows or by verticals. So how can I make to drap the cards by mouse to proper destination (exchanging cards for match). And then I lke to store how many times the player makes the moving process of cards and time as well. And if three of cards are in match condition , I want them to be disappear from the interface boxes. Finally, evth gone.. I want to print out the move times and the time to take long for the game.
Pls help me with that! coz I being just a beginner!
|
|
|
|
|
Perhaps if you're a beginner, and you're choosing hobby projects to start with, the fact that you've posted 5 questions in the past few hours is an indication that you need to choose a simpler project. What have you already written ? Did you take the time to learn C# before starting with windows programs ?
Christian Graus - C++ MVP
|
|
|
|
|
How can I add icon to the context Menue?
thanks
MD_NADA
|
|
|
|
|
Put your icon in the Image property of the menu item collection in the context menu.
|
|
|
|
|
How to recieve a List of files from a ftp?
I am sending command LIST.
but recieving only:
150 Opening ASCII mode data connection for /bin/ls.
226 Transfer complete.
I am sure that on ftp must be some folders and files (ftp clients show them).
But I dont receive anything between 150 and 226.
So I read the answer from ftp:
Socket clientSocket;
string message;
byte[] buffer = byte[512];
int bytes;
while (clientSocket.Available == 0)
{
System.Threading.Thread.Sleep(50);
}
while (clientSocket.Available > 0)
{
bytes = clientSocket.Receive(buffer, buffer.Length, 0);
message += Encoding.ASCII.GetString(buffer, 0, (int)bytes);
System.Threading.Thread.Sleep(50);
}
|
|
|
|
|
If I remember correctly, FTP uses two TCP ports (20 and 21), the latter for sending/receiving commands and the former for sending/receiving data. Are you connecting to the server's port 20?
|
|
|
|
|
Thank you for idea!
The solution was so, that i was have to create one more data socket for passive mode on another port and receive data from this socket.
|
|
|
|
|
In the old days of basic we used to use a for loop to slow down the processing so the user could see changes that would happen too fast to see. (ie. changes to images in a game or data being displayed.
I am trying to show some pictureboxe changes in sequence (not animation), but the process runs so fast I only see the last change, the same with playing several wav sounds I only hear the last one.
there should be an easy way to delay the ballance of code from running so the user has time to see or hear the changes.
Thanks,
|
|
|
|
|
|
as I understand the timer's tick event, it runs whatever method you want at the set amount of ticks. But the rest of the code will be running meanwhile. did I not totaly understand, is there a way to pause the code till the tick event happens?
Thanks for your reply.
|
|
|
|
|
Do the opposite. Run the animation code only on the tick event.
|
|
|
|
|
Thanks: Will have to think about that, it might require 40-50% of my code being inside the tick event.
but will look at it.
Thanks again
|
|
|
|
|
Argus2 wrote: it might require 40-50% of my code being inside the tick event.
You can always call your code from the tick event, it needn't be literally "inside" it.
|
|
|
|
|
Use the Thread.Sleep method to make the thread wait for a number of milliseconds.
---
b { font-weight: normal; }
|
|
|
|
|
System.Threading.Thread.Sleep(1000);
will pause the thread for 1000 milliseconds.
|
|
|
|
|
Thanks that looks like it will work just fine for me..
Thanks Everyone.
|
|
|
|
|
How could i do to copy a file to a shared folder ( that shared folder is on server ) by using Windows service?
when I ran code : File.Copy("c:\\tempFile.txt","\\\\192.168.0.1\\SharedFile\\tempFile.txt",True) in windows application, it worked well. But when i used windows service, that code didn't work.
It seems that shared folder is not found when you use path:"\\\\192.168.0.1\\SharedFile\\tempFile.txt". It seems that Windows Service
will run under another desktop which is different from the logoned
interactive desktop.
So how could i access shared folder by using windows service?
Please give me some advice. Any ideas will be welcomed
|
|
|
|
|
Run the service using a domain account that has the proper permissions on both computers.
|
|
|
|
|
Thanks for your reply.
Yes, i have permission on both computers. I run following code :
<br />
'Domain account<br />
String user = "UserName";<br />
String p = "PassWord";<br />
SecureString pass = new SecureString();<br />
<br />
'Create pass<br />
for(i=0; i< p.Length; i++)<br />
pass.AppendChar(p[i]);<br />
<br />
'Copy file<br />
Process.start("cmd","/c copy c:\\temp.txt \\\\ServerName\\SharedFolder",user,pass, "DomainName");
That code run well on winform application but when running in windows service, it alerts "Access denies". It means it couldn't find the correct path to SharedFolder when using windows service.
So please tell me what correct path to access that SharedFolder by using Windows Service?
-- modified at 9:57 Sunday 26th November, 2006
|
|
|
|
|
You need to install your service itself under a domain user account. This is done in the ServiceProcessInstaller, search for something like:
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.User;<br />
this.serviceProcessInstaller1.Username = "abcd@mydomain.com";<br />
this.serviceProcessInstaller1.Password = "mypassword";
This would already be the working version. You probably have a ServiceAccount.System or something else. And null values as username and password.
Try it this way.
|
|
|
|
|
Is it possible to utilize a clientRectangle and to assign the background image to that client rectangle outside of a paint event handler? When there is a control and a background image is assigned like this:
Control ctrl = ((Control)sender);
ctrl.BackgroundImage = (path to an image file);
then the control either increases or decreases in size, then the background image is distorted or stretched in the process. However, if a control has a clientRectangle positioned on it, the clientRectangle would not be distorted or stretched accordingly. The code would be like so:
public Rectangle clientRectangle;
...
int intWidth = 78, intHeight = 109;
clientRectangle = new Rectangle(0, 0, intWidth, intHeight);
The question is, is it possible to assign a background image to the clientRectangle from the Form Load event handler instead of from a paint event handler.
It is my understanding that the PaintEventArgs from the paint event handler is required to assign the image to the clientRectangle. Is there another way that the image file could be assigned to the client rectangle, although not from the paint event handler but instead from the Form Load event handler? The code would be like so.
p.Graphics.DrawImage(imgFile, clientRectangle);
Would appreciate some input as to how to approach this issue so that the background image is not assigned to the control but instead to the clientRectangle.
-- modified at 17:15 Saturday 25th November, 2006
|
|
|
|