Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[question] help in C# please
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Tue Dec 18, 2007 4:06 pm    Post subject: Reply with quote

Uhh...

What version of the .NET framework are you using?

Edit:

Try this

Code:

private void Save_Click(object sender, EventArgs e) //Save would be the button name
{
    SaveFileDialog sfd = new SaveFileDialog();
    sfd.DefaultExt = "txt";
    sfd.AddExtension = true;
    sfd.FileName = FileName.Text; //Assuming FileName is the name of the textbox with that says "file name here" or whatever
     sfd.FileOk += new CancelEventHandler(sfd_FileOk);
     sfd.Show();
}

private void sfd_FileOk(object sender, CancelEventArgs e)
{
     SaveFileDialog sfd = (SaveFileDialog)sender;
     string Path = sfd.FileName.Substring(sfd.FileName.LastIndexOf("\\")+1);

     StreamWriter sw = StreamWriter.Null;     

     try
     {
            File.Delete(Path); //Just in case it already exists
            StreamWriter sw = File.CreateText(Path);
            sw.WriteLine(Code.Text);
      }
      catch (Exception e)
      {
            MessageBox.Show(e.ToString());
      }
      finally
      {
            sw.Flush();
            sw.Dispose();
            sw.Close();
      }
}

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue Dec 18, 2007 11:09 pm    Post subject: Reply with quote

i'm using visual studio 2003 and now i get error in the line sw.dispose();

'System.IO.TextWriter.Dispose(bool)' is inaccessible due to its protection level

Crying or Very sad

_________________
Stylo
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed Dec 19, 2007 6:42 am    Post subject: Reply with quote

Try:
Code:
using (StreamWriter WFile = new StreamWriter("File.txt"))
{
WFile.Write("Line 1" + Environment.NewLine + "Line 2");
}
Back to top
View user's profile Send private message
richie86
Grandmaster Cheater
Reputation: 0

Joined: 13 Jan 2006
Posts: 664

PostPosted: Wed Dec 19, 2007 8:27 am    Post subject: Reply with quote

if not mistaken ->>WriteAllText is in vs2005 not vs2003.
_________________
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed Dec 19, 2007 8:34 am    Post subject: Reply with quote

Use 2005+. Very Happy
Back to top
View user's profile Send private message
richie86
Grandmaster Cheater
Reputation: 0

Joined: 13 Jan 2006
Posts: 664

PostPosted: Wed Dec 19, 2007 8:37 am    Post subject: Reply with quote

Symbol try this xD
http://forum.cheatengine.org/viewtopic.php?t=171523

_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Dec 19, 2007 1:04 pm    Post subject: Reply with quote

ok thank u every1 i found an alternative way to save my files anyway thank u very much for ur help and i'll try get 2005+ :>
_________________
Stylo
Back to top
View user's profile Send private message
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Wed Dec 19, 2007 1:44 pm    Post subject: Reply with quote

On Solution Explorer:

Properties >> double click Settings.Settings.

Add a new item. Name for example: TextBox.
Type: String Scope: User Blank for Value.

Now go to your form and add this.

Code:
public void Close()
{
Settings.Default.TextBox1 = *Name of TextBox here*.Text;
}


Then put this onto Form Load:

Code:
private void Form1_Load(object sender, EventArgs e)
{
     *TextBox name here*.Text = Settings.Default.TextBox1;     
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites