Rebeca Rdi
Rebeca Rdi

Reputation: 55

C# Overwrite file failed badly

Tried several times to make this work but with several failures. let me explain what i've tried to do:
1.Unrar the files in zip format (working)
2.Unraring to a named directory (unrars)
3.Copying from unrars folder to another folder(not working)
So my question is : Did i used a correct overwrite format? i set the bool overwrite to true.

foreach (string fisier in Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories))
            {
                System.IO.File.Copy(fisier, fisier.Replace(TheSourcePath, TheDestinationPath), true);

            }

Upvotes: 1

Views: 150

Answers (1)

BanksySan
BanksySan

Reputation: 28540

Seems like an odd way to get the destination path to me, can't you just have it as a string?

It might be that the string replace isn't creating a valid path.

I assume `TheDestinationPath' is a const, in which case is won't have the file name on it, or you'll be copying over a file from the second iteration.

Upvotes: 0

Related Questions