Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 27th, 2006, 5:13 PM   #11
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 377
Rep Power: 0 King is an unknown quantity at this point
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!
King is offline   Reply With Quote
Old Aug 27th, 2006, 5:36 PM   #12
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
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
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Aug 27th, 2006, 7:19 PM   #13
AntiNinja
Hobbyist Programmer
 
AntiNinja's Avatar
 
Join Date: Jun 2006
Location: The States
Posts: 101
Rep Power: 3 AntiNinja is on a distinguished road
Send a message via AIM to AntiNinja Send a message via Yahoo to AntiNinja
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.
AntiNinja is offline   Reply With Quote
Old Aug 27th, 2006, 8:23 PM   #14
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 377
Rep Power: 0 King is an unknown quantity at this point
AntiNinja is correct, you need the double backslash for it to work.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Aug 28th, 2006, 12:26 AM   #15
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Oh yeah... i forgot about escape characters
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Aug 28th, 2006, 12:31 AM   #16
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
All right i tried what you suggested and got the same exact error. I can't see what i'm doing wrong.
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Aug 28th, 2006, 12:32 AM   #17
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Never mind i forgot something. I think i got it now
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Aug 28th, 2006, 12:34 AM   #18
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
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.
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Aug 28th, 2006, 12:36 AM   #19
AntiNinja
Hobbyist Programmer
 
AntiNinja's Avatar
 
Join Date: Jun 2006
Location: The States
Posts: 101
Rep Power: 3 AntiNinja is on a distinguished road
Send a message via AIM to AntiNinja Send a message via Yahoo to AntiNinja
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.
AntiNinja is offline   Reply With Quote
Old Aug 28th, 2006, 12:39 AM   #20
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
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.
Booooze is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:02 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC