GDI+ Fehler Windows 2000
- VB.NET
Sie verwenden einen veralteten Browser (%browser%) mit Sicherheitsschwachstellen und können nicht alle Funktionen dieser Webseite nutzen.
Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können.
Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können.
Es gibt 14 Antworten in diesem Thema. Der letzte Beitrag () ist von Gelöschter Benutzer.
-
-
-
-
-
-
-
Codoptimierung kommt dann wenns funktioniert
VB.NET-Quellcode
- Imports System.IO
- Public Class Form1
- Private prc As Process
- Sub hund()
- MsgBox("Keine weiteren Bilder gefunden!", MsgBoxStyle.Information)
- Timer1.Start()
- End Sub
- Dim PfadAufDemDevice As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Bilderpfad.txt")
- Dim LW As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Laufwerkbuchstabe.txt")
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Dim i As Integer = 0
- For Each item In Directory.GetFiles(PfadAufDemDevice)
- i = i + 1
- Next
- If i = 0 Then
- Me.Hide()
- Else
- ListBox1.Items.Clear()
- Me.Show()
- Timer1.Stop()
- Timer2.Start()
- For Each item In Directory.GetFiles(PfadAufDemDevice)
- ListBox1.Items.Add(item)
- Next
- Try
- PictureBox1.Load(ListBox1.Items(0))
- Catch ex As Exception
- Timer1.Stop()
- Timer2.Start()
- MsgBox("Keine Bilder vorhanden!", MsgBoxStyle.Exclamation)
- End Try
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If ComboBox1.Text = "" Then
- MsgBox("Benutzer wählen!", MsgBoxStyle.Exclamation)
- Exit Sub
- End If
- Dim SpeicherPfad As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\resources\Benutzer\" & namenlabel.Text)
- Dim bmp As New Bitmap(PictureBox1.Image)
- Dim g As Graphics = Graphics.FromImage(bmp)
- Dim i As Integer = 1
- If zusatztb.Text = "" Then
- g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution - 50), 200, 50))
- g.FillRectangle(Brushes.Black, New Rectangle(bmp.Width - 190, 0, bmp.Width, 25))
- g.DrawString(DateTime.Now, New Font("Arial", 14), Brushes.White, New Point(bmp.Width - 190, 0))
- g.DrawString(namenlabel.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - (bmp.VerticalResolution - 60)))
- Else
- g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution - 50), 300, 50))
- g.FillRectangle(Brushes.Black, New Rectangle(0, bmp.Height - (bmp.VerticalResolution), 200, 50))
- g.FillRectangle(Brushes.Black, New Rectangle(bmp.Width - 190, 0, bmp.Width, 25))
- g.DrawString(zusatztb.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - (bmp.VerticalResolution - 60)))
- g.DrawString(DateTime.Now, New Font("Arial", 14), Brushes.White, New Point(bmp.Width - 190, 0))
- g.DrawString(namenlabel.Text, New Font("Arial", 20), Brushes.White, New Point(10, bmp.Height - bmp.VerticalResolution + 10))
- End If
- Do While File.Exists(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
- i += 1
- Loop
- bmp.Save(SpeicherPfad & "\" & namenlabel.Text & "-" & i & ".jpg")
- Try
- My.Computer.FileSystem.WriteAllText("Z:\Gruppe-EDV\Mathis\Domänen Programme\Programm Logs\Foto Import.txt", vbNewLine & "[" & DateTime.Now & "] Foto wurde importiert nach " & namenlabel.Text, True)
- Catch ex As Exception
- End Try
- File.Delete(ListBox1.Items(0))
- ListBox1.Items.Remove(ListBox1.Items(0))
- Try
- PictureBox1.Load(ListBox1.Items(0))
- Catch ex As Exception
- hund()
- Exit Sub
- End Try
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- For Each items In New System.IO.DirectoryInfo(Application.StartupPath & "\resources\Benutzer").GetFiles()
- ComboBox1.Items.Add(items)
- Next
- Timer1.Start()
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
- namenlabel.Text = ComboBox1.Text
- End Sub
- Private Sub AnlegenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnlegenToolStripMenuItem.Click
- Process.Start("osk.exe")
- Dim Name As String = InputBox("Name eingeben: ")
- Dim SpeicherOrt As String
- If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
- SpeicherOrt = FolderBrowserDialog1.SelectedPath
- End If
- Try
- My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\resources\Benutzer\" & Name, SpeicherOrt, False)
- For Each item In System.Diagnostics.Process.GetProcesses
- If item.ProcessName = "osk" Then
- item.Kill()
- End If
- Next
- MsgBox("Benutzer wurde angelegt!", MsgBoxStyle.Information)
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- End Sub
- Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
- Dim i As Integer = 0
- For Each item In Directory.GetFiles(PfadAufDemDevice)
- i = i + 1
- Next
- If i = 0 Then
- Me.Hide()
- Else
- Me.Show()
- Timer1.Start()
- Timer2.Stop()
- End If
- End Sub
- Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
- e.Cancel = True
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Process.Start(Application.StartupPath & "\resources\readme.pdf")
- End Sub
- Private Sub zusatztb_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zusatztb.Enter
- Process.Start("osk")
- End Sub
- Private Sub zusatztb_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zusatztb.Leave
- For Each item In System.Diagnostics.Process.GetProcesses
- If item.ProcessName = "osk" Then
- item.Kill()
- End If
- Next
- End Sub
- Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
- ComboBox1.Focus()
- End Sub
- End Class
-
Du scheinst ein großer Freund von Try-Catch-Blöcken zu sein. Das ist Pfui (jedenfalls in 95% aller Fälle). Zudem hast du leere Catch-Zweige, setzt Pfade blind mit & zusammen (dafür gibs Path.Combine).
Ob in einer Listbox ein Item existiert, fragt man über die Count-Eigenschaft der Listbox.Items ab.
Der Fehler tritt offenbar beim Speichern des Image im Button1_Click-Event statt (steht in deiner Meldung)
Fiel Fergnügen
VatterSeit 26.Mai 2012 Oppa! -
-
kikipetro schrieb:
Aber wie fang ich an den fehler zu suchen ?
Setze einen Haltepunkt in jede Prozedur (nacheinander) und arbeite sie schrittweise durch.
Überprüfe, ob das Programm das macht, was es machen soll. Wenn nicht: Fehler gefunden.
Sieh Dir den Inhalt von Variablen an. Stimmt er nicht: Fehler gefunden.
Also losFalls Du diesen Code kopierst, achte auf die C&P-Bremse.
Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch
Ein guter .NET-Snippetkonverter (der ist verfügbar).
Programmierfragen über PN / Konversation werden ignoriert! -
-
-
-
Hi
für Pfad-Verknüpfungen verwendet man System.IO.Path.Combine oder Äquivalentes. namenlabel.Text enthält gültige Werte? Du hast Schreibrechte im spezifizierten Pfad (gabs das unter Win2000 schon?). Für mehrfache einfache String-Verknüpfungen solltest du String.Concat verwenden. Übrigens wäre es günstig, kein allgemeingültiges Try-Catch zu verwenden, sondern beim Catch-Block z.B. IOException etc. abzufragen. Die Exceptions kannst du auf der MSDN oder im Object Browser ermitteln und entsprechend darauf reagieren.
Hier wäre z.B. der Artikel für Image.Save:
msdn.microsoft.com/de-de/library/ktx83wah.aspx
Image.Save-Methode (String) (System.Drawing) schrieb:
Das Bild wurde im falschen Bildformat gespeichert.
– oder –
Das Bild wurde in derselben Datei gespeichert, aus der es erstellt wurde.
Gruß
~blaze~ -
-
Ähnliche Themen
-
kikipetro - - Sonstige Problemstellungen
-
wejherowo112 - - Sonstige Problemstellungen
-
Dennis336 - - Sonstige Problemstellungen
-
4 Benutzer haben hier geschrieben
- Gast (12)
- Vatter (1)
- RodFromGermany (1)
- ~blaze~ (1)