using System;
using System.Windows.Forms;
using System.IO;
public class MainClass
{
public static void Main()
{
OpenFileDialog dlgOpen = new OpenFileDialog();
dlgOpen.Title="Select file to back up";
if (dlgOpen.ShowDialog() == DialogResult.OK)
{
FileStream inStream = File.OpenRead(dlgOpen.FileName);
FileStream outStream = File.OpenWrite(dlgOpen.FileName + ".bak");
BufferedStream bufInStream = new BufferedStream(inStream);
BufferedStream bufOutStream = new BufferedStream(outStream);
byte[] buf = new byte[4096];
int bytesRead;
while ((bytesRead = bufInStream.Read(buf, 0, 4096)) > 0)
bufOutStream.Write(buf, 0, bytesRead);
bufOutStream.Flush();
bufOutStream.Close();
bufInStream.Close();
outStream.Close();
inStream.Close();
}
}
}
|