"device not ready" when using File.Copy () in C #

I am trying to move databases from one SQL server to another. I do this through a console written in C #. The methodology is as follows. First, I detach the database, move the data and log files to a new location, and then attach the files from there. However, after detaching the file, I cannot copy the data and log files. The error I get is: "the device is not ready." I use network paths for both the source and destination. I use File.Copy () to move files, and I have permissions to create files in the corresponding folders.

+3
source share
1 answer

When you guess "the device is not ready," is not the C # exception generated by the File Copy command. Possible exceptions:

UnauthorizedAccessException, ArgumentException, ArgumentNullException, 
PathTooLongException, DirectoryNotFoundException, FileNotFoundException, 
IOException, NotSupportedException

Thus, this “error” may be something that is created internally, in accordance with other comments, additional information is required. To debug this problem, I suggest the following

  • Place a breakpoint in your code where the text string "device is not ready" is present in your code.
  • Verify that both paths in your code are valid paths
  • Is your program designed to handle UNC paths or file paths?
  • The exception may be quietly encrypted, but you need to debug it to find this.
  • , Windows, ? services.msc run, SQL Server ( SQL), . .

.

+3

Source: https://habr.com/ru/post/1766772/


All Articles