Answered by:
Need help with designing a form to copy the most recent file in a directory into the directory of the users choosing.

Question
-
So I am trying to make a form where the user chooses a preset directory based upon radio button selection & copies the newest file from directory "c:\tmp\" into the directory they chose using a button press to execute the transfer. Can anyone help me?Friday, April 15, 2016 11:09 AM
Answers
-
Hello,
It is best for you to begin with what you have tried so far e.g. a small code sample placed into a code block using the code button. Provides as many details as possible.
If there is no current code take a look at the following thread and this thread to see if this might be of assistance.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
- Proposed as answer by Albert_Zhang Monday, April 25, 2016 4:14 PM
- Marked as answer by Herro wongMicrosoft contingent staff Tuesday, April 26, 2016 1:22 AM
Friday, April 15, 2016 11:35 AM -
FileSystemWatcher Class can monitor folder for new files using only the Created event I believe since all you want to know is if a new file is placed in C:\Temp.
If the user has a default location to copy the file to then you could use a user scoped setting to store the default copy to location to so your app could auto-copy new files in C:\Temp to that location.
You don't mention why files would go to C:\Temp or how they get there or why a user may want the new file to go someplace other than a location they already predetermined. Why would a button press be necessary to execute the transfer? With FileSystemWatcher, once the app runs the first time and the user determines a folder location to transfer new files in C:\Temp to, FileSystemWatcher can have code to auto-copy new files in C:\Temp to users predetermined location as well as code to notify the user this has occured.
La vida loca
- Proposed as answer by Albert_Zhang Monday, April 25, 2016 4:14 PM
- Marked as answer by Herro wongMicrosoft contingent staff Tuesday, April 26, 2016 1:22 AM
Friday, April 15, 2016 3:21 PM
All replies
-
Hello,
It is best for you to begin with what you have tried so far e.g. a small code sample placed into a code block using the code button. Provides as many details as possible.
If there is no current code take a look at the following thread and this thread to see if this might be of assistance.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
- Proposed as answer by Albert_Zhang Monday, April 25, 2016 4:14 PM
- Marked as answer by Herro wongMicrosoft contingent staff Tuesday, April 26, 2016 1:22 AM
Friday, April 15, 2016 11:35 AM -
So I am trying to make a form where the user chooses a preset directory based upon radio button selection & copies the newest file from directory "c:\tmp\" into the directory they chose using a button press to execute the transfer. Can anyone help me?
There are a few things that you need to think through before you start:
First, when the user chooses a directory to locate the most recent file, do you want it to include sub-directories to look through also?
Secondly, define what "newest file" means. Do you mean the most recent creation date/time or the most recent modified date/time?
Lastly, when the program then goes to copy that to a directory that the user selects, what if a file by that name already exists? Do you want to overwrite it, rename it, or just what?
Give those things some thought. It's not difficult to do but you do need to clearly define how it's to work.
Knowledge rests not upon truth alone, but upon error also. Carl Jung
Friday, April 15, 2016 1:00 PM -
FileSystemWatcher Class can monitor folder for new files using only the Created event I believe since all you want to know is if a new file is placed in C:\Temp.
If the user has a default location to copy the file to then you could use a user scoped setting to store the default copy to location to so your app could auto-copy new files in C:\Temp to that location.
You don't mention why files would go to C:\Temp or how they get there or why a user may want the new file to go someplace other than a location they already predetermined. Why would a button press be necessary to execute the transfer? With FileSystemWatcher, once the app runs the first time and the user determines a folder location to transfer new files in C:\Temp to, FileSystemWatcher can have code to auto-copy new files in C:\Temp to users predetermined location as well as code to notify the user this has occured.
La vida loca
- Proposed as answer by Albert_Zhang Monday, April 25, 2016 4:14 PM
- Marked as answer by Herro wongMicrosoft contingent staff Tuesday, April 26, 2016 1:22 AM
Friday, April 15, 2016 3:21 PM