BGC Tools
Static Public Member Functions
BGC.IO.Utility Class Reference

Static Public Member Functions

static void SafeMove (string srcPath, string dstPath, bool deleteOnDuplicate=true)
 Move file from the source path to the destination path. More...
 

Detailed Description

Definition at line 5 of file Utility.cs.

Member Function Documentation

◆ SafeMove()

static void BGC.IO.Utility.SafeMove ( string  srcPath,
string  dstPath,
bool  deleteOnDuplicate = true 
)
inlinestatic

Move file from the source path to the destination path.

WARNING: if you set delete on duplicate to false it will not move src to dst. If you set it to true it will delete the current file at dst and move src. After, it wil destroy the file at src.

Parameters
srcPath
dstPath

Definition at line 17 of file Utility.cs.

18  {
19  bool canMoveFile = true;
20  if (File.Exists(dstPath))
21  {
22  if (deleteOnDuplicate)
23  {
24  File.Delete(dstPath);
25  }
26  else
27  {
28  canMoveFile = false;
29  }
30  }
31 
32  if(canMoveFile)
33  {
34  File.Move(srcPath, dstPath);
35  }
36  }

The documentation for this class was generated from the following file: