Hallo Community,
ich habe folgendes Problem:
Ich habe eine SQLite-Datenbank, dort habe ich eine Tabelle protokolldatei die folgende Werte enthält:
Die Tabelle wird auch angelegt und ich kann dort auch meine Dateien hineinspeichern.
Jetzt ist aber das Problem, dass ich die Datei erstelle, aber nach dem Process.Start wird die Datei direkt wieder gelöscht.
Woran kann dies liegen ?
Hier der Code:
Ich hoffe, Ihr könnt mir weiterhelfen.
vivil
ich habe folgendes Problem:
Ich habe eine SQLite-Datenbank, dort habe ich eine Tabelle protokolldatei die folgende Werte enthält:
Die Tabelle wird auch angelegt und ich kann dort auch meine Dateien hineinspeichern.
Jetzt ist aber das Problem, dass ich die Datei erstelle, aber nach dem Process.Start wird die Datei direkt wieder gelöscht.
Woran kann dies liegen ?
Hier der Code:
VB.NET-Quellcode
- 'Blob-Protokoll öffnen:
- If e.RowIndex >= 0 Then
- 'Dim sProkotoll As String
- 'sProkotoll = Application.StartupPath & "\" & dgProtokolle.Rows(e.RowIndex).Cells("protokolldatei").Value.ToString()
- 'Process.Start(sProkotoll)
- Dim filename As String
- Dim file() As Byte
- Try
- 'Dateinamen + Pfad in Variable speichern
- filename = Application.StartupPath & "\cache\" & dgProtokolle.Rows(e.RowIndex).Cells("protokolldatei").Value.ToString
- 'Prüfen, ob das Verzeichnis vorhanden ist
- If Directory.Exists(Application.StartupPath & "\cache") Then
- 'Prüfen, ob die Datei in dem Verzeichnis schon vorhanden ist
- If System.IO.File.Exists(filename) Then
- 'Datei öffnen
- Process.Start(filename)
- Else
- 'Wenn die Datei noch nicht vorhanden ist,
- 'dann Speichern und öffnen der Datei in das Verzeichnis
- file = dgProtokolle.Rows(e.RowIndex).Cells("datei").Value
- Dim K As Long
- K = UBound(file)
- Dim fs As New FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write)
- fs.Write(file, 0, K + 1)
- fs.Close()
- Process.Start(filename)
- End If
- Else
- 'Wenn das Verzeichnis nicht vorhanden ist,
- 'dann das Verzeichnis erstellen, die Datei in dem Verzeichnis
- 'abspeichern und die Datei öffnen
- Directory.CreateDirectory(Application.StartupPath & "\cache")
- file = dgProtokolle.Rows(e.RowIndex).Cells("datei").Value
- Dim K As Long
- K = UBound(file)
- Dim fs As New FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write)
- fs.Write(file, 0, K)
- fs.Close()
- Process.Start(filename)
- End If
- Catch ex As Exception
- MessageBox.Show(ex.ToString())
- End Try
- End If
Ich hoffe, Ihr könnt mir weiterhelfen.
vivil