Hey Leute!
Ich progge momentan nen LogOn Screen Changer, und hab folgendes Problem:
Also in der Form ist ne PictureBox, in der das Bild, was vorher in nem OpenFileDialog() ausgewählt wurde, angezeigt wird, oder halt falls noch nichts ausgewählt wurde, der akutelle Background.
Damit das funktioniert muss das Bild ein JPEG sein und < 256 kB. Also hab ich ein If-Statement erstellt:
Das ist zwar nur ein Ausschnitt, sollte aber denke ich ausreichen. Das Problem ist jetzt, dass das Prog stoppt an der Stelle, wo die Datei hinkopiert werden muss, mit der Begründung "Der Prozess kann nicht auf die Datei "C:\Users\*****\Desktop\backgroundDefault.jpg" zugreifen, da sie von einem anderen Prozess verwendet wird." Diese Meldung kommt aber nur, wenn die Datei bereits existiert
Ich hoffe ihr könnt mir helfen, DANKE !
Ich progge momentan nen LogOn Screen Changer, und hab folgendes Problem:
Also in der Form ist ne PictureBox, in der das Bild, was vorher in nem OpenFileDialog() ausgewählt wurde, angezeigt wird, oder halt falls noch nichts ausgewählt wurde, der akutelle Background.
Damit das funktioniert muss das Bild ein JPEG sein und < 256 kB. Also hab ich ein If-Statement erstellt:
VB.NET-Quellcode
- Dim picturesizeKB As Single = Math.Round(My.Computer.FileSystem.GetFileInfo(imagepath).Length / 1024, 2) 'Size in Bytes - Divided by 1024 -> KiloByte
- Dim filename As String = My.Computer.FileSystem.GetFileInfo(imagepath).Name 'Name of the file, i.e. "ABCDEFG.bmp"
- Dim fileformat As String = filename.Substring(filename.IndexOf(".") + 1) 'Locates the dot in the name and returns all chars behind it --> "bmp"
- If fileformat <> "jpg" And picturesizeKB > 256 Then
- MsgBox(info1, MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "Size and Format Exception") 'info1 is a String with the Error "Worng Fileformat and Size"
- If MsgBoxResult.Ok = 1 Then
- My.Computer.FileSystem.CopyFile(imagepath, destinationpath & "backgroundDefault.jpg", True) ' Copy, Rename, Convert File
- MsgBox("Modification successful" & vbCrLf & picturesizeKB & ps)
- End If
- ElseIf picturesizeKB > 256 Then
- ElseIf fileformat <> "jpg" Then
- Else
- End If
Das ist zwar nur ein Ausschnitt, sollte aber denke ich ausreichen. Das Problem ist jetzt, dass das Prog stoppt an der Stelle, wo die Datei hinkopiert werden muss, mit der Begründung "Der Prozess kann nicht auf die Datei "C:\Users\*****\Desktop\backgroundDefault.jpg" zugreifen, da sie von einem anderen Prozess verwendet wird." Diese Meldung kommt aber nur, wenn die Datei bereits existiert
Ich hoffe ihr könnt mir helfen, DANKE !
»There's no need to "teach" atheism. It's the natural result of education without indoctrination.« — Ricky Gervais