Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Like we can keep displaying a message by writing a messagebox statement in a timer control event. Same way i want to keep copying a file(text file) to another location until a timer is not stopped by the user. I can copy/move file successfully but i want to continue copying. Its a windows application in c#.net.
Posted
Comments
[no name] 28-Jun-13 10:09am    
Okay.... and the actual problem is....?
Mahesh Bailwal 28-Jun-13 10:10am    
You can use timer control for that also, is there any problem in that?

1 solution

Hey,
you could try something like this:

int i = 0;
var timer = new Timer();
timer.Interval = 500;
timer.Start();
timer.Tick += delegate {
//Creates a simple .txt file
System.IO.File.Create(/*sample path+filename*/ @ "c:\myfile" + i.ToString();+".txt");
//appends the text to the .txt file. first parameter: file, where you append the text,
//second parameter: define which text you want to append
System.IO.File.AppendAllText(@ "c:\myfile" + i.ToString();,
File.ReadAllText(/*sample path+filename*/@"c:\file_you_want_to_copy");

//increase the integer to create another file next time.
i++;
};
 
Share this answer
 
Comments
Pankaj Mahor 28-Jun-13 11:24am    
Any other way to do it?
BiteForce 28-Jun-13 11:30am    
System.IO.File.Copy(string, string);
BiteForce 28-Jun-13 11:31am    
I forgot, that this method also exists, sorry.
Pankaj Mahor 28-Jun-13 11:58am    
How to use it?
BiteForce 30-Jun-13 11:10am    
System.IO.File.Copy([the file to copy], [the destination file]);
both parameters are strings.
BG

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900