![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Professional Programmer
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 377
Rep Power: 0
![]() |
Well you declared 'sw' in your contractor, so your button click event won’t see it because it’s out of scope. Declare it above your constructor and make it private.
__________________
I am Addicted to Linux! |
|
|
|
|
|
#12 |
|
Expert Programmer
|
ok i tried this
[php] using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.IO; namespace IOTest { public partial class MainForm { //[STAThread] /*FileStream file = new FileStream("c:\test.txt", FileMode.CreateNew, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter("c:\test.txt");*/ private FileStream file = new FileStream("c:\test.txt", FileMode.CreateNew, FileAccess.ReadWrite); private StreamWriter sw = new StreamWriter("c:\test.txt"); public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } public MainForm() { InitializeComponent(); /*FileStream file = new FileStream("c:\test.txt", FileMode.CreateNew, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(file);*/ } void MainFormLoad(object sender, System.EventArgs e) { } void Button1Click(object sender, System.EventArgs e) { sw.Write("Hello World"); } } } [/php] and got this error Exception System.ArgumentException was thrown in debuggee: Illegal characters in path. CheckInvalidPathChars() GetFileName() .ctor() .ctor() - c:\Documents and Settings\David\My Documents\SharpDevelop Projects\IOTest\IOTest\MainForm.cs:14,3 Main() - c:\Documents and Settings\David\My Documents\SharpDevelop Projects\IOTest\IOTest\MainForm.cs:20,4 I'm feeling really lost
__________________
|
|
|
|
|
|
#13 |
|
Hobbyist Programmer
|
try "C:\\test.txt"
I'm not sure though I dont use C#, but in Java you have to do that for backslashes.
__________________
Pain is just weakness leaving the body.
|
|
|
|
|
|
#14 |
|
Professional Programmer
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 377
Rep Power: 0
![]() |
AntiNinja is correct, you need the double backslash for it to work.
__________________
I am Addicted to Linux! |
|
|
|
|
|
#15 |
|
Expert Programmer
|
Oh yeah... i forgot about escape characters
__________________
|
|
|
|
|
|
#16 |
|
Expert Programmer
|
All right i tried what you suggested and got the same exact error. I can't see what i'm doing wrong.
__________________
|
|
|
|
|
|
#17 |
|
Expert Programmer
|
Never mind i forgot something. I think i got it now
__________________
|
|
|
|
|
|
#18 |
|
Expert Programmer
|
Ok it does not give me the same error... in fact it doesnt give me any error but It does not appear in the document... I'm sorry if i am asking to many questions but it just seems like i'm not getting anywhere with this lately.
__________________
|
|
|
|
|
|
#19 |
|
Hobbyist Programmer
|
try private StreamWriter sw = new StreamWriter(file); as thats what they have in the tutorial, but again no C# experience sorry
![]()
__________________
Pain is just weakness leaving the body.
|
|
|
|
|
|
#20 |
|
Expert Programmer
|
Maybe try closing the file?
sw.Close() Try that, then view it. [EDIT] That should do it, I'm just looking at some of my code now, and it should work for you. Also, check out the dispose method. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OnlineTextEditor.Com! | Sane | Show Off Your Open Source Projects | 43 | Jun 16th, 2006 8:55 AM |
| Help in QBASIC (I think it's similar to VB) | phoenix987 | Visual Basic | 3 | May 9th, 2005 12:33 PM |
| Help with a QBASIC program | phoenix987 | Other Programming Languages | 4 | May 5th, 2005 12:27 PM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |