0

I'm trying to copy sqlite db file and access it over the network.

Issue is on server while trying to access the copy of sqlite db even though when i run application on localhost, it works absolutely fine.

public bool CopyDB()
    {
        string fileName = "spiceworks_prod.db";
        string sourcePath = "\\\\vapp01\\Spiceworks\\db";
        string targetPath = "\\\\vapp01\\Spiceworks\\db\\backup\\temp";



        // Use Path class to manipulate file and directory paths.
        string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
        string destFile = System.IO.Path.Combine(targetPath, fileName);

        // To copy a folder's contents to a new location:
        // Create a new target folder, if necessary.
        if (!System.IO.Directory.Exists(targetPath))
        {
            System.IO.Directory.CreateDirectory(targetPath);
        }

        // To copy a file to another location and 
        // overwrite the destination file if it already exists.
        if (!System.IO.Directory.Exists(destFile))
        {
            File.SetAttributes(destFile, FileAttributes.Normal);
            System.IO.File.Copy(sourceFile, destFile, true);

            return true;
        }
        else
        {
            return false;
        }

Unable to open databasefile

Here is a picture of the error description

KenLe
  • 1
  • 2
  • Did you check file permissions? – Yamuk Feb 07 '19 at 00:31
  • 1
    Your apppool unlikely has permissions unless you have set them implicitly, however we cant tell because you have included no error information – TheGeneral Feb 07 '19 at 00:46
  • @MichaelRandall i added a pic of errors showing, "unable to open database file". is there anywhere i need to set my application pool permission apart from folder security properties? – KenLe Feb 07 '19 at 01:05
  • @YamaçKurtuluş yea, i did that. security is set to everyone with full control access. – KenLe Feb 07 '19 at 01:07
  • try to check this https://stackoverflow.com/questions/7670289/sqlite3-operationalerror-unable-to-open-database-file – Vijunav Vastivch Feb 07 '19 at 01:47

1 Answers1

0

I have managed to find out the actual cause of it

The Problem i found is having to do with the sqlite database in the server. somehow it doesnt allow copying over network.

To fix this. i have generate a script to copy the file and trigger it everytime appplication is running.

KenLe
  • 1
  • 2