Copy files again
C # code
- File.Copy (Server.MapPath ("File relative path copied"), Server.MapPath ("Destination relative path"), true);
Note: If the third parameter is true, a file with the same name as the target location will be overwritten.
C # code
- File.Copy (Server.MapPath (". /.. /appdir/temp.jpg "), Server.MapPath (". /.. /appkir/tteemmpp.jpg "), true);
If you do not need to Server.MapPath ("path"), to copy the file will be an error, the following errors
C # code
- File.Copy (".. /.. /appdir/temp.jpg ", Server.MapPath (". /.. /appkir/tteemmpp.jpg "), true); //Wrong wording
However, the path of the copied location can be used without the following correct
C # code
- File.Copy (Server.MapPath (". /.. /appdir/temp.jpg "), ". /.. /appkir/tteemmpp.jpg ", true); //correct
Similarly, there are
File.delete ("");
System.Drawing.Image.FromFile ("");
And so on, all must use absolute path or add Server.MapPath ("path"), relative path, if use relative path error, may try Server.MapPath ("path");
ASP. net file copy or delete with relative path, file.copy with relative path, skillfully copy file with relative path