Any filename instead of specified one
Code:
System.IO.File.Move(@"ConsoleApplication2.exe", @"C:\CA\ConsoleApplication2.exe");
I am using this code and I was wondering if I can set the @"ConsoleApplication2.exe", where the "ConsoleApplication2.exe" part can be a variable. Which I mean instead of specifying the filename, there is a variable instead for the file's current name. I hope you guys will understand what I am asking.
Example:
%var = file's current name
Say my file's name is TODD.exe so %var = Todd.exe
Code:
System.IO.File.Move(@"%var", @"C:\CA\%var");
Re: Any filename instead of specified one
You're trying to make this more complex than it is. Move takes two string arguments. In the code you've posted you're passing literal strings but you can pass string variables too, just like you can pass variables to any method, as long as they're the correct type.
Code:
string var = "Todd.exe"; // This file name can come from anywhere, e.g. literal, TextBox, file, registry, etc.
System.IO.File.Move(var, @"C:\CA\" + var);