jimy neutron
Messages postés491Date d'inscriptionmercredi 1 février 2006StatutMembreDernière intervention18 novembre 2016
-
31 déc. 2012 à 12:15
jimy neutron
Messages postés491Date d'inscriptionmercredi 1 février 2006StatutMembreDernière intervention18 novembre 2016
-
31 déc. 2012 à 13:20
Bonjour à tous,
Je développe une petite appli qui regroupe les renseignements concernant mes séances photo.
Voila un bout de code qui me permets de joindre un photo à la fiche d'une séance photo. Si celle-ci n'existe pas, pas de soucis. Mais si je souhaite changer la photo d'un fiche qui en a deja une, ça merdouille!
Access to the path 'Y:\...\Index.jpg' is denied.
Pourtant, avec ceci, je pensais libérer le fichier "index.jpg"
'Ouverture du dialogue
If OpenFileDialog_Shoot.ShowDialog() = DialogResult.OK Then
Source = OpenFileDialog_Shoot.FileName
NameLink = Dir(Source)
DirSource = My.Computer.FileSystem.CurrentDirectory
'Si les fichiers exitent deja dans TEMP
If Exists(LienBase & "\Folder_Temp" & NameLink) Then
System.IO.File.Delete(LienBase & "\Folder_Temp" & NameLink)
End If
If Exists(LienBase & "\Folder_Temp\index.jpg") Then
System.IO.File.Delete(LienBase & "\Folder_Temp\index.jpg")
End If
'Copie du fichier source dans le fichier temporaire
System.IO.File.Copy(Source, LienBase & "\Folder_Temp" & NameLink, True)
'Renommer le fichier
'My.Computer.FileSystem.RenameFile(LienBase & "\Folder_Temp" & NameLink, "Index.jpg")
System.IO.File.Move(LienBase & "\Folder_Temp" & NameLink, LienBase & "\Folder_Temp\Index.jpg")
'Si le fichier "index.jpg" exitent dans la destination
Me.Pct_S_Visu.Image = My.Resources.homme
Me.FlowLayout_Photo.Controls.Clear()
Me.FlowLayout_Photo.Refresh()
If Exists(DirSource & "\Index.jpg") Then
System.IO.File.Delete(DirSource & "\Index.jpg")
End If
'Copie du fichier dans le fichier d'origine
System.IO.File.Copy(LienBase & "\Folder_Temp\Index.jpg", DirSource & "\Index.jpg", True)
'Supprimer le fichier temporaire
System.IO.File.Delete(LienBase & "\Folder_Temp\Index.jpg")
Charge plutôt ton image depuis un stream fermé automatiquement
using reader as new IO.filestream("image.jpg", IO.filemode.open)
moncontrole.image = Image.fromstream(reader)
end using
my.computer.filesystem.deletefile(...