我正在尝试复制sqlite db文件并通过网络访问它。
当我尝试访问sqlite db的副本时,问题在服务器上,尽管当我在localhost上运行应用程序时,它工作得非常好。
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;
}无法打开数据库文件
发布于 2019-02-08 08:23:56
我设法找出了它的真正原因。
我发现的问题与服务器中的sqlite数据库有关。不知何故,它不允许通过网络复制。
来解决这个问题。我已经生成了一个脚本来复制文件,并在每次应用程序运行时触发它。
https://stackoverflow.com/questions/54564648
复制相似问题