mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-22 05:48:37 +00:00
Copy works
This commit is contained in:
parent
37ec73cba4
commit
bf905d6e47
1 changed files with 12 additions and 29 deletions
|
|
@ -162,47 +162,30 @@ namespace Cosmos.System_Plugs.System.IO
|
|||
|
||||
public static void Copy(string srcFile, string destFile)
|
||||
{
|
||||
if (File.Exists(destFile))
|
||||
try
|
||||
{
|
||||
throw new IOException();
|
||||
byte[] srcFileBytes = File.ReadAllBytes(srcFile);
|
||||
File.WriteAllBytes(destFile, srcFileBytes);
|
||||
}
|
||||
else
|
||||
catch (IOException ioEx)
|
||||
{
|
||||
using (var xFS = new FileStream(srcFile, FileMode.Open))
|
||||
{
|
||||
var xBuff = new byte[(int)xFS.Length];
|
||||
var yFS = new FileStream(destFile, FileMode.Create);
|
||||
yFS.Write(xBuff, 0, xBuff.Length);
|
||||
}
|
||||
throw new IOException("File Copy", ioEx);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Copy(string srcFile, string destFile, bool overwriting)
|
||||
{
|
||||
if (File.Exists(destFile))
|
||||
if (overwriting)
|
||||
{
|
||||
if (overwriting)
|
||||
File.Delete(destFile);
|
||||
try
|
||||
{
|
||||
File.Delete(destFile);
|
||||
using (var xFS = new FileStream(srcFile, FileMode.Open))
|
||||
{
|
||||
var xBuff = new byte[(int)xFS.Length];
|
||||
var yFS = new FileStream(destFile, FileMode.Create);
|
||||
yFS.Write(xBuff, 0, xBuff.Length);
|
||||
}
|
||||
byte[] srcFileBytes = File.ReadAllBytes(srcFile);
|
||||
File.WriteAllBytes(destFile, srcFileBytes);
|
||||
}
|
||||
else
|
||||
catch (IOException ioEx)
|
||||
{
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var xFS = new FileStream(srcFile, FileMode.Open))
|
||||
{
|
||||
var xBuff = new byte[(int)xFS.Length];
|
||||
var yFS = new FileStream(destFile, FileMode.Create);
|
||||
yFS.Write(xBuff, 0, xBuff.Length);
|
||||
throw new IOException("File Copy", ioEx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue