Datei öffnen und konvertieren

  • VB.NET

Es gibt 4 Antworten in diesem Thema. Der letzte Beitrag () ist von Asti.

    Datei öffnen und konvertieren

    Hallo...

    Könnte jemand den Code mal durchlesen und mir wenn möglich helfen? Ist allerdings in WPF.
    Ich hab mehrere MsgBoxen eingebaut, um zu prüfen wann er rausfliegt (Fehlermeldung bekomm ich leider nicht).

    .isd ist die eigene Datei
    Arbeitsflaeche_Ink ist ein InkCanvas


    VB.NET-Quellcode

    1. Dim OpenFileDialog1 As New Microsoft.Win32.OpenFileDialog
    2. MsgBox(My.Application.StartupUri.LocalPath)
    3. MsgBox(System.IO.Directory.GetCurrentDirectory.ToString)
    4. Dim AllText, LineOfText As String
    5. OpenFileDialog1.Filter = "XAML-Dateien(*.xaml)|*.xaml|Meine Datei(*.isd)|*.isd"
    6. OpenFileDialog1.ShowDialog() 'display Open dialog box
    7. If OpenFileDialog1.FileName <> "" Then
    8. Try 'open file and trap any errors using handler
    9. FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
    10. Do Until EOF(1) 'read lines from file
    11. LineOfText = LineInput(1)
    12. 'add each line to the AllText variable
    13. AllText = AllText & LineOfText & vbCrLf
    14. Loop
    15. MsgBox(AllText)
    16. If System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory.ToString & "\oe.xaml") = True Then
    17. System.IO.File.Delete(System.IO.Directory.GetCurrentDirectory.ToString & "\oe.xaml")
    18. System.IO.File.Create(System.IO.Directory.GetCurrentDirectory.ToString & "\oe.xaml")
    19. FileOpen(1, System.IO.Directory.GetCurrentDirectory.ToString & "\oe.xaml", OpenMode.Output)
    20. PrintLine(1, AllText) 'copy text to disk
    21. FileClose(1)
    22. End If
    23. MsgBox("sowiet")
    24. Dim fs As New System.IO.FileStream(System.IO.Directory.GetCurrentDirectory.ToString & "\oe.xaml", IO.FileMode.Open)
    25. MsgBox("sowiet2")
    26. Arbeitsflaeche_Ink = System.Windows.Markup.XamlReader.Load(fs)
    27. MsgBox("sowiet3")
    28. System.IO.File.Delete(System.IO.Directory.GetCurrentDirectory.ToString & "\oe.xaml")
    29. MsgBox("sowiet4")
    30. Catch
    31. MsgBox("Öffnen der Datei nicht möglich.")
    32. Finally
    33. FileClose(1) 'close file
    34. End Try
    35. End If
    ja werd ich ändern
    allerdings funktioniert alles bis

    VB.NET-Quellcode

    1. MsgBox("sowiet")


    Danach geht er ins Catch über und gibt die MsgBox aus

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Asti“ ()