copy a file to a folder
C#
3
Posts
3
Posters
0
Views
1
Watching
-
i m try to save a file but it does not work can anybody suggest me some good tectics using C# codings
public void copyBookDatabase()
{string filename ="mydb.mdb"; //whatever the name of your file is you want copied string destfileName = filename; string sourcePath = Environment.CurrentDirectory; // get the working directory // string sourcePath = @"C:\\"; string targetPath = @"C:\\DB\_Backup\\"; //// Use Path class to manipulate file and directory paths. string sourceFile = System.IO.Path.Combine(sourcePath, fileName); string destFile = System.IO.Path.Combine(targetPath, destfileName); //// To copy a folder's contents to a new location: //// Create a new target folder, if necessary. //if (!System.IO.Directory.Exists(targetPath)) //{ // System.IO.Directory.CreateDirectory(targetPath); //} //// To copy a file to another location and //// overwrite the destination file if it already exists. System.IO.File.Copy(sourceFile, destFile, true); }
hope this helps
-
i m try to save a file but it does not work can anybody suggest me some good tectics using C# codings