Cannot create a file when it already exists using File.Move

Rain

I was trying to move a file from my Resx to my PC, but I'm keep having problems.

So I import a folder named "bad" in the Resources and I use the File.Move method to move the folder "bad" into my PC. But the program keeps crashing because it says: Cannot create a file when its already exists.

Here the code I use:

//txtpath is the root folder. I let the user choose the root folder and save it in txtpath.text

private void btnbadname_Click(object sender, EventArgs e)
{
        string source = "Resources\bad";
        string destination = txtpath.Text + @"\RADS\projects\lol_air_client\releases\0.0.1.74\deploy\assets\locale\App";

        File.Move(source, destination);

        MessageBox.Show("脏话ID已开启, 教程请点击下面的链接");
}
Tony

The destination Directory cannot exist. In your code you are creating the Directory if it doesn't exist and then trying to move your directory, the Move Method will create the directory for you. If the Directory already exists you will need to Delete it or Move it.

See: Cannot create a file when that file already exists when using Directory.Move

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

mklink error: Cannot create a file when that file already exists

From Dev

How to Fix MVC Cannot create/shadow copy 'XXX' when that file already exists

From Dev

Cannot create file database.mdf because it already exists

From Dev

[kernel32.dll]CreateHardLink fails with "Cannot create a file when that file already exists" on Azure Website during RavenDb Embedded backup

From Dev

Move and replace if same file name already exists?

From Dev

File Already Exists When Moving File

From Dev

cannot create regular file 'filename': File exists

From Dev

How to create a new output file in R if a file with that name already exists?

From Dev

How to create a new output file in R if a file with that name already exists?

From Dev

How to move/rename file using WinSCP .NET Assembly when target file exist already?

From Dev

How to move/rename file using WinSCP .NET Assembly when target file exist already?

From Dev

If File Already Exists Rename it

From Dev

Error in file already exists

From Dev

How to create an empty folder when a file with the folder's name already exists?

From Dev

How to create an empty folder when a file with the folder's name already exists?

From Dev

Warning message if file name already exists when creating a pdf file

From Dev

How to remove line `v u` from a file when line `u v` already exists using unix command

From Dev

chmod: cannot access 'file' : No such file or directory error when the file exists

From Dev

Command line: create file with new filename if the filename already exists

From Dev

Command line: create file with new filename if the filename already exists

From Dev

Create a new file, but add a number if the filename already exists

From Dev

Table already exists error when trying to import sql file

From Dev

This code is running well for upload and extension check but not when file already exists

From Dev

Open returns (-1) with O_CREAT when file already exists

From Dev

This code is running well for upload and extension check but not when file already exists

From Dev

Open returns (-1) with O_CREAT when file already exists

From Dev

Checking if destination file already exists

From Dev

Rename a file if same already exists

From Dev

Test to see if a file already exists

Related Related

  1. 1

    mklink error: Cannot create a file when that file already exists

  2. 2

    How to Fix MVC Cannot create/shadow copy 'XXX' when that file already exists

  3. 3

    Cannot create file database.mdf because it already exists

  4. 4

    [kernel32.dll]CreateHardLink fails with "Cannot create a file when that file already exists" on Azure Website during RavenDb Embedded backup

  5. 5

    Move and replace if same file name already exists?

  6. 6

    File Already Exists When Moving File

  7. 7

    cannot create regular file 'filename': File exists

  8. 8

    How to create a new output file in R if a file with that name already exists?

  9. 9

    How to create a new output file in R if a file with that name already exists?

  10. 10

    How to move/rename file using WinSCP .NET Assembly when target file exist already?

  11. 11

    How to move/rename file using WinSCP .NET Assembly when target file exist already?

  12. 12

    If File Already Exists Rename it

  13. 13

    Error in file already exists

  14. 14

    How to create an empty folder when a file with the folder's name already exists?

  15. 15

    How to create an empty folder when a file with the folder's name already exists?

  16. 16

    Warning message if file name already exists when creating a pdf file

  17. 17

    How to remove line `v u` from a file when line `u v` already exists using unix command

  18. 18

    chmod: cannot access 'file' : No such file or directory error when the file exists

  19. 19

    Command line: create file with new filename if the filename already exists

  20. 20

    Command line: create file with new filename if the filename already exists

  21. 21

    Create a new file, but add a number if the filename already exists

  22. 22

    Table already exists error when trying to import sql file

  23. 23

    This code is running well for upload and extension check but not when file already exists

  24. 24

    Open returns (-1) with O_CREAT when file already exists

  25. 25

    This code is running well for upload and extension check but not when file already exists

  26. 26

    Open returns (-1) with O_CREAT when file already exists

  27. 27

    Checking if destination file already exists

  28. 28

    Rename a file if same already exists

  29. 29

    Test to see if a file already exists

HotTag

Archive