尝试将文件从路径A阴影复制到路径B,但它不断抛出错误消息
{“无法加载文件或程序集'AlphaVSS.x64,版本= 1.4.0.0,文化=中性,PublicKeyToken = 959d3993561034e3'或其依赖项之一。尝试加载格式错误的程序。”}
我尝试的代码
Public Sub copyFile(baza As String, destination As String)
If IO.File.Exists(baza) Then
Dim myFileInfo As FileInfo
myFileInfo = New FileInfo(baza)
Dim _volume As String = myFileInfo.Directory.Root.Name
Dim _vssImplementation As IVssImplementation = VssUtils.LoadImplementation()
Dim _backup As IVssBackupComponents = _vssImplementation.CreateVssBackupComponents()
_backup.InitializeForBackup(Nothing)
_backup.GatherWriterMetadata()
_backup.SetContext(VssVolumeSnapshotAttributes.Persistent Or VssVolumeSnapshotAttributes.NoAutoRelease)
_backup.SetBackupState(False, True, Alphaleonis.Win32.Vss.VssBackupType.Full, False)
Dim MyGuid01 As Guid = _backup.StartSnapshotSet()
Dim MyGuid02 As Guid = _backup.AddToSnapshotSet(_volume, Guid.Empty)
_backup.PrepareForBackup()
_backup.DoSnapshotSet()
_backup.ExposeSnapshot(MyGuid02, Nothing, VssVolumeSnapshotAttributes.ExposedLocally, "L:")
Dim sVSSFile2 As String = baza.Replace(_volume, "L:\")
If (File.Exists(sVSSFile2)) Then
System.IO.File.Copy(sVSSFile2, destination + "\" + System.IO.Path.GetFileName(baza), True)
For Each prop As VssSnapshotProperties In _backup.QuerySnapshots
If (prop.ExposedName = "L:\") Then
Console.WriteLine("File found !")
_backup.DeleteSnapshot(prop.SnapshotId, True)
End If
Next
_backup = Nothing
Console.WriteLine("File copied")
Else
Console.WriteLine("------------------------------------------")
Console.WriteLine("File not exist: " + baza)
End If
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
我有VSS nuget软件包和参考
它在网上抛出错误
Dim _vssImplementation As IVssImplementation = VssUtils.LoadImplementation()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
228 次 |
最近记录: |