Fehler beim beschreiben von einer Datei

  • VB.NET
  • .NET (FX) 4.5–4.8

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von can0199.

    Fehler beim beschreiben von einer Datei

    Guten Abend,
    ich habe da ein Problem mit meinem kleinem Programm und zwar soll es beim starten eine Datei erstellen dies klappt auch, im nächsten Schritt soll die Datei beschrieben werden dies klappt nicht denn dann kommt immer folgender Fehler:
    Spoiler anzeigen
    ​System.IO.IOException wurde nicht behandelt.
    HResult=-2147024864
    Message=Der Prozess kann nicht auf die Datei "c:\users\****\documents\visual studio 2015\Projects\Win7AnnoStarterKit_Uninstall\Win7AnnoStarterKit_Uninstall\bin\Debug\uninstall.txt" zugreifen, da sie von einem anderen Prozess verwendet wird.
    Source=mscorlib
    StackTrace:
    bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    bei System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    bei System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
    bei System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
    bei System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
    bei System.IO.File.WriteAllText(String path, String contents)
    bei Win7AnnoStarterKit_Uninstall.Form1.Form1_Load(Object sender, EventArgs e) in c:\users\***\documents\visual studio 2015\Projects\Win7AnnoStarterKit_Uninstall\Win7AnnoStarterKit_Uninstall\Form1.vb:Zeile 8.
    bei System.EventHandler.Invoke(Object sender, EventArgs e)
    bei System.Windows.Forms.Form.OnLoad(EventArgs e)
    bei System.Windows.Forms.Form.OnCreateControl()
    bei System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    bei System.Windows.Forms.Control.CreateControl()
    bei System.Windows.Forms.Control.WmShowWindow(Message& m)
    bei System.Windows.Forms.Control.WndProc(Message& m)
    bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    bei System.Windows.Forms.Form.WmShowWindow(Message& m)
    bei System.Windows.Forms.Form.WndProc(Message& m)
    bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    InnerException:


    Hier mein Code ausschnitt:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. ​IO.File.Create(Application.StartupPath & "\uninstall.txt")
    2. IO.File.WriteAllText(Application.StartupPath & "\uninstall.txt", path)


    Ich hoffe jemand kann mir helfen ist bestimmt nicht so schwer aber ich bin noch Anfänger deshalb checke ich das bestimmt nicht:D

    LG
    Streich diese Zeile ersatzlos:

    can0199 schrieb:

    VB.NET-Quellcode

    1. ​IO.File.Create(Application.StartupPath & "\uninstall.txt")
    Falls 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!