Is it possible to copy a pst file using c# with outlook open?
Here is the code i have got already but it still gives me the error :The process cannot access the file 'filepath' because it is being used by another process.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace outlookPSTCopy
{
class Program
{
    static void Main(string[] args)
    {
        string done = "the file is done copying";//done massage
        string copyFrom = args[0];
        string copyTo = args[1];
        Console.WriteLine(copyTo);
        Console.ReadLine();
        try
        {
            //start of test
            using (var inputFile = File.Open(copyFrom, FileMode.Open,    FileAccess.ReadWrite, FileShare.Read))
            {
                using (var outputFile = new FileStream(copyTo, FileMode.Create))
                {
                    var buffer = new byte[0x10000];
                    int bytes;
                    while ((bytes = inputFile.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        outputFile.Write(buffer, 0, bytes);
                    }
                }
            }
            //end of test
            //System.IO.File.Copy(copyFrom, copyTo, true);
        }
        catch (Exception copyError)
        {
            Console.WriteLine("{0} Second exception caught.", copyError);
        }
        Console.WriteLine("{0} ", done);
        Console.ReadLine();
    }
}
}
Thank you for your help!
 
    