Click here to Skip to main content
15,894,192 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to write the ms access db from one folder to another with out any dattalose. I try some code but it giving error like this
"
C++
Access to the path 'C:\Documents and Settings\Duane.DGAGENCI-FA286T\My Documents\ECatalog\ECatalog Update\Database\CANASIA TOYS & GIFTS' is denied.
"

Here is my code wat i can change from this

C++
if (File.Exists("C:\\Documents and Settings\\Duane.DGAGENCI-FA286T\\My Documents\\ECatalog\\ECatalog Update\\Database\\CANASIA TOYS & GIFTS\\CANASIA TOYS & GIFTS PRODUCTS.mdb"))
                {
                    File.Delete("C:\\Documents and Settings\\Duane.DGAGENCI-FA286T\\My Documents\\ECatalog\\ECatalog Update\\Database\\CANASIA TOYS & GIFTS\\CANASIA TOYS & GIFTS PRODUCTS.mdb");
                }
                string path1 = "C:\\Documents and Settings\\Duane.DGAGENCI-FA286T\\My Documents\\ECatalog\\ECatalog Update\\Database\\CANASIA TOYS & GIFTS";
                byte[] ReadDb = ReadFile("C:\\Documents and Settings\\Duane.DGAGENCI-FA286T\\My Documents\\Canasia\\ECatalog April 12-1\\MergeMacro\\CANASIA TOYS & GIFTS PRODUCTS.mdb");
                MemoryStream msdb = new MemoryStream(ReadDb);
                FileStream fsdb = new FileStream(path1, FileMode.Open, FileAccess.ReadWrite);
                byte[] writedb = msdb.ToArray();
                fsdb.Write(writedb, 0, writedb.Length);
                msdb.Close();
                fsdb.Close();

anyone please solve the problem. i could not solve that issue please send charect coding in c#.net
Posted

1 solution

Seems that you don't have right privileges to the target directory. You could modify the privileges of the directory or raise the privileges of your code.

Also perhaps you could simply use Copy[^]

Additional warning: If someone is accessing and modifying the database at the time you copy it, the result may not be usable.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900