IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Shadow Copy (Snapshot)


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2010
    Messages : 2
    Par défaut Shadow Copy (Snapshot)
    Bonjour,
    je dois créer un programme de Backup automtique. Un problème persiste est la copie du *.pst d'Outlook constamment ouvert chez les utilisateurs. Après de nombreuses recherches, voici ce que j'ai trouvé et réalisé.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    'Le fichier est ouvert -- Utilisation de snapshot
        Sub snapshot(ByVal chem_source As String, ByVal chem_dest As String, ByVal date_modif As Date, ByVal date_zip As Date)
            Console.WriteLine("je suis dans cette fonction")
     
            Dim vssImplementation As IVssImplementation
            Dim vssbackup As IVssBackupComponents
            Dim snapshot As Guid
     
     
            vssImplementation = VssUtils.LoadImplementation()
            vssbackup = vssImplementation.CreateVssBackupComponents()
            vssbackup.InitializeForBackup(Nothing)
            'vssbackup.SetContext()
            vssbackup.SetBackupState(False, True, VssBackupType.Copy, False)
     
            Using async As IVssAsync = vssbackup.GatherWriterMetadata()
                async.Wait()
            End Using
     
            'Console.WriteLine("Test d'écriture")
     
            snapshot = vssbackup.StartSnapshotSet()
     
            Dim IsSadowCopySupported As Boolean = vssbackup.IsVolumeSupported("d:\", Guid.Empty)
     
            'If IsSadowCopySupported = True Then
            '    Console.WriteLine("Volume supporté par les Shadow Copy")
            'End If
     
            Dim SnapShotId As Guid = vssbackup.AddToSnapshotSet("d:\", Guid.Empty)
            'Console.WriteLine("Voici l'Id du SnapShot: {0}", SnapShotId)
     
            Using async As IVssAsync = vssbackup.PrepareForBackup
                async.Wait()
            End Using
            Using async As IVssAsync = vssbackup.DoSnapshotSet
                async.Wait()
            End Using
     
     
            Dim SnapShotProp As VssSnapshotProperties = vssbackup.GetSnapshotProperties(SnapShotId)
            Dim SnapShotDevice As String = SnapShotProp.SnapshotDeviceObject
            Console.WriteLine("SnapShotDevice: {0}", SnapShotDevice)
     
            Dim entier As Integer = chem_source.Length()
            entier = entier - 2
            Dim chem_source2 As String = Right(chem_source, entier)
     
            Dim SourceFile As String = SnapShotDevice & "\" & chem_source2
            Console.WriteLine(SourceFile)
            entier = chem_dest.Length()
            entier = entier - 4
            Dim chem_dest2 As String = Left(chem_dest, entier)
            Dim TargetFile As String = chem_dest2
     
     
     
            Using async As IVssAsync = vssbackup.BackupComplete
                async.Wait()
            End Using
     
            My.Computer.FileSystem.CopyFile(SourceFile, TargetFile)
     
     
     
            Dim pbstrXML As String = vssbackup.SaveAsXml()
            Console.WriteLine("pbstrXML: {0}", pbstrXML)
            Dim sw As System.IO.StreamWriter = Nothing
            sw = New System.IO.StreamWriter("C:\fic.xml")
            sw.WriteLine("{0}", pbstrXML)
            sw.Close()
     
        End Sub
    Une erreur persiste lors de la copie du fichier utilisant cette technologie :

    Les chemins qui commencent par \\?\GlobalRoot sont internes au noyau et ne doivent pas être ouverts par les applications gérées.
    Qui peut m'aider?

    Merci d'avance

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    17
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Octobre 2002
    Messages : 17
    Par défaut
    A priori tu ne peux pas accéder directement avec les fonctions my.computer.filesystem.
    En revanche, tu peux le faire en utilisant les API windows.
    Par exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    <DllImport( _
                "kernel32.dll", _
                CharSet:=CharSet.Auto, _
                SetLastError:=True)> _
                Private Shared Function CopyFile( _
                <[In]()> ByVal lpExistingFileName As String, _
                <[In]()> ByVal lpNewFileName As String, _
                <[In]()> ByRef bFailIfExists As Byte) _
                               As Long
     
            End Function
    Si tu remplaces ton
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    My.Computer.FileSystem.CopyFile(SourceFile, TargetFile)
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    CopyFile(SourceFile, TargetFile, False)
    ça marchera.

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2010
    Messages : 2
    Par défaut
    je devais remplacer ce code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    My.Computer.FileSystem.CopyFile(SourceFile, TargetFile)
    par

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Alphaleonis.Win32.Filesystem.File.Copy(SourceFile, TargetFile)

    Merci quand même.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Volume Shadow Copy manquant
    Par guitar.bruno dans le forum Windows XP
    Réponses: 1
    Dernier message: 17/04/2013, 10h28
  2. [WS 2003] Cliché instantané (shadow copy)
    Par souf954 dans le forum Windows Serveur
    Réponses: 1
    Dernier message: 16/08/2011, 11h45
  3. Volume Shadow Copy Service
    Par scolyo dans le forum C++
    Réponses: 0
    Dernier message: 13/02/2008, 09h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo