System.IO.File.Copy C# (CSharp) Method

Copy() public static method

public static Copy ( string sourceFileName, string destFileName ) : void
sourceFileName string
destFileName string
return void
        public static void Copy(string sourceFileName, string destFileName) { }
        public static void Copy(string sourceFileName, string destFileName, bool overwrite) { }

Same methods

File::Copy ( String sourceFileName, String destFileName ) : void
File::Copy ( String sourceFileName, String destFileName, bool overwrite ) : void
File::Copy ( string sourceFileName, string destFileName, bool overwrite ) : void

Usage Example

        private async Task CopyConfigFile()
        {
            await Task.Run(() =>
            {
                try
                {
                    string sharedConfigFile = Path.Combine(SscUpdateManager.VersionFolder, GlobalResources.ConfigPath);
                    string curConfigFile    = Path.Combine(Environment.CurrentDirectory, GlobalResources.ConfigPath);

                    bool hasSharedConfig = File.Exists(sharedConfigFile);
                    bool useSharedConfig = Settings.Default.UseUserConfig;

                    Log.Logger.Debug($"has shared config?{hasSharedConfig}, useSharedConfig?{useSharedConfig}");

                    if (hasSharedConfig && useSharedConfig)
                    {
                        Log.Logger.Debug($"【copy config file】:copy {sharedConfigFile} to {curConfigFile}");

                        File.Copy(sharedConfigFile, curConfigFile, true);
                    }
                }
                catch (Exception ex)
                {
                    Log.Logger.Error($"【copy config file exception】:{ex}");
                    Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        SscDialog dialog = new SscDialog(Messages.ErrorCopyConfigFile);
                        dialog.ShowDialog();
                        Current.Shutdown();
                    }));
                }
            });
        }
All Usage Examples Of System.IO.File::Copy