Your variables source
and target
are member variables of your class. The following code is allowed:
DirectoryInfo source = new DirectoryInfo("C:\\belgeler");
DirectoryInfo target = new DirectoryInfo("E:\\Backup");
It is permitted because it is not referencing any other member variables of your class. But when you try:
DirectoryInfo source = new DirectoryInfo(from_path);
DirectoryInfo target = new DirectoryInfo(to_path);
This references other variables from_path
and to_path
which is not permitted.
Move these variables to be local variables and that should solve your issue.