无法访问服务器上的sqlite数据库

时间:2019-02-07 00:28:12

标签: c# asp.net-mvc-4

我正在尝试复制sqlite db文件并通过网络访问它。

即使我在本地主机上运行应用程序,尝试访问sqlite db的副本时,问题也在服务器上。

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;
        }

无法打开数据库文件

Here is a picture of the error description

1 个答案:

答案 0 :(得分:0)

我设法找出了它的真正原因

我发现的问题与服务器中的sqlite数据库有关。不知何故,它不允许通过网络复制。

要解决此问题。我已经生成了一个脚本来复制文件,并在每次运行应用程序时触发它。