RichBox speichern...
-
HI Leute,
hoffe meine Postings sind so besser als die üblichen. *lächel*
PROBLEMSTELLUNG:
Ich möchte den Inhalt einer RichtTextBox mit Zeilenumbrüchen speichern. Der folgende COde kam dabei heraus. Die Fehlermeldung zeigt das ich hier nicht so fit bin. Wer hat das schon mal gemacht und kann mir mir einem kleinen Beispiel den richtigen Weg zeigen?
QUELLCODE:
string verzeichnis = @"C:\MoSysWorkSpace\logs\"; string datei = verzeichnis + FehlerDateiTXT.Text; FileStream fs = new FileStream(datei, FileMode.Open, FileAccess.Read); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(FehlerDateiTXT.Text); sw.Close(); fs.Close();
FEHELRMELDUNG:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.************** Exception Text **************
System.ArgumentException: Stream was not writable.
at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(Stream stream)
at MoSysControl.MainForm.ButtonFehlerQuittierenClick(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
MoSysControl
Assembly Version: 1.0.2706.26411
Win32 Version: 1.0.2706.26411
CodeBase: file:///G:/DatenPfad/dirk.moll/SharpDevelop%20Projects/Release/MoSysControl.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.[/quote]Danke für Eure Hilfe!
Euer J.S.
-
dieses posting steht auch auf stpotlight. in der zeit, in der du verschiede foren mit deinem muell zupostest haettest du auch in der onlinehilfe nachschauen koennen!
-
Servus,
muss ich leider dem Vorposter recht geben.
Trotzdem, schau dir mal die Fehlermeldung genauer an:
System.ArgumentException: Stream was not writable.
in Bezug auf die folgende Zeile:
FileStream fs = new FileStream(datei, FileMode.Open, FileAccess.Read);
Such mal in der MSDN nach StreamWriter / FileStream. Dort gibts wunderschöne Beispiele.
mfg
Hellsgore