Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to copy files to a predefined folder. How to write the code so that it acts similar to doing ctrl+v after browsing to the folder. Just click a button windows takes it from there.(in c#)

Note: I need to let windows know that a certain file has to be copied to a certain location. Hooking into one of the windows processes i guess.
Posted
Updated 25-Sep-13 7:50am
v4
Comments
Rick van Woudenberg 25-Sep-13 7:28am    
Not sure what you mean though. Could you please provide us with more information or details. Copying files in c# is pretty straightforward. File.Copy(src_filename, dst_filename) usually does the trick. But I guess if it was that simply, you wouldn't be asking this question.
cs3infomat 25-Sep-13 14:05pm    
Is there a way to fire paste event in explorer programmatically with my parameters?
[no name] 25-Sep-13 7:49am    
"dint work" is not helpful unless you post some code. This is very basic stuff.
cs3infomat 25-Sep-13 10:37am    
ok...forget i have codes.I just want to do normal copy paste... i want windows explorer to do it.what happens when we press ctrl+v i want same thing in a button click in a form with windows ui.

See the answer on this[^] page.

/ravi
 
Share this answer
 
Comments
cs3infomat 26-Sep-13 0:54am    
Iam getting an error my doesnt exist in current context. Imported visual basic. Does this work in xp. Will form become unresponsive?
Ravi Bhavnani 26-Sep-13 8:00am    
1 - Did you import Microsoft.VisualBasic.Devices?
2 - As the SO post says, this is available in Vista and later.
3 - Did you read the MSDN article?

/ravi
See File.Copy[^].
 
Share this answer
 
Comments
cs3infomat 25-Sep-13 10:49am    
Please i dont want to copy directly. i have a form and a button. Source and destination is selected. Then when in press the button windows has to copy file to that path. Just like sending a message to windows explorer. UI should be responsive.
Richard MacCutchan 25-Sep-13 10:57am    
Then do the file copying in a background worker thread.
cs3infomat 25-Sep-13 13:39pm    
Why cant i use windows api by telling what and where to paste?
[no name] 25-Sep-13 13:52pm    
What do you think File.Copy does?
cs3infomat 25-Sep-13 14:04pm    
If i use file.copy form becomes unresponsive. Then i need to use a background worker or something, show progress bar etc. Is there a way to fire paste event in explorer programmatically with my parameters?
 
Share this answer
 
Comments
cs3infomat 26-Sep-13 4:22am    
Is there any example? Does it work in xp too?
Richard MacCutchan 26-Sep-13 4:39am    
No idea, but Google will help you.
added reference to the project downloaded from http://msdn.microsoft.com/en-us/magazine/cc163304.aspx and called inbuild copy function and its all good.... Thanks guys
 
Share this answer
 

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