I am not able to move a text file immediately after having successfully created. Below is what the code snippet looks like:
Only the C:/Employee.txt has been moved to C:/Archived but not C:/NewEmployee.txt. Yet, it is possible to move C:/NewEmployee.txt to C:/Archived if the file is not created by this process. As a result, I need your feedback on the following areas wrt moving files:
( i ) How to unlock or free up C:/NewEmployee.txt prior to moving to C:\Archived. An alternative approach would be to create it under C:\Archived but it is needed in C:/ for other purpose which I won’t elaborate any further?
( ii ) How to overwrite C:/NewEmployee.txt if the file already exists in C:/Archived? Again, it is possible to delete the existing file first but would like to know whether the overwriting of file is possible on Windows platform?
You were absolutely spot on even though it was not obvious to have picked that up. I solved it by moving the declaration of the two variables to the beginning of the main method so that both declarations and closing them are referencing the same variables.