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 


[C#] OpenFileDialog help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri Dec 28, 2007 1:05 pm    Post subject: [C#] OpenFileDialog help Reply with quote

i'v created button and i wanna make him to open an asm file into my TextBox this is my code:
Code:

    private void OpenClick(object sender, EventArgs e)
    {
        OpenFileDialog open = new OpenFileDialog();
        open.DefaultExt = "asm";
        open.AddExtension = true;
        open.FileName = fileName.Text;
        open.Filter = "Assembly Files (*.asm)|*.asm||*.extention";
        open.FileOk += new CancelEventHandler(openFileOk);
        open.ShowDialog();
    }
    private void openFileOk(object sender, CancelEventArgs e)
    {
        OpenFileDialog open = (OpenFileDialog)sender;
        // need help here... :<
    }


now i dont know how to continue it... can some1 help me out please?

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

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

PostPosted: Fri Dec 28, 2007 1:26 pm    Post subject: Re: [C#] OpenFileDialog help Reply with quote

1qaz wrote:
i'v created button and i wanna make him to open an asm file into my TextBox this is my code:
Code:

    private void OpenClick(object sender, EventArgs e)
    {
        OpenFileDialog open = new OpenFileDialog();
        open.DefaultExt = "asm";
        open.AddExtension = true;
        open.FileName = fileName.Text;
        open.Filter = "Assembly Files (*.asm)|*.asm||*.extention";
        open.FileOk += new CancelEventHandler(openFileOk);
        open.ShowDialog();
    }
    private void openFileOk(object sender, CancelEventArgs e)
    {
        OpenFileDialog open = (OpenFileDialog)sender;
        // need help here... :<
    }


now i dont know how to continue it... can some1 help me out please?


Try this:

Code:

private void openFileOk(object sender, CancelEventArgs e)
{
    OpenFileDialog ofd = (OpenFileDialog)sender;
    string FileName = ofd.FileName;

    StreamReader sr = StreamReader.null;

     try
     {
           sr = new StreamReader(FileName);
           TheCodeTextBox.Text = sr.ReadToEnd(); //I think that's it. I don't remember though; if that isn't it, try what ever's closest           
      }

      catch(Exception e)
      {
             MessageBox.Show(e.ToString());
       }

        finally
       {
            sr.Close();
            sr.Dispose();
       }
}

_________________
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: Fri Dec 28, 2007 1:40 pm    Post subject: Reply with quote

thanks bro. Very Happy
_________________
Stylo
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

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

PostPosted: Fri Dec 28, 2007 1:46 pm    Post subject: Reply with quote

Anytime. =)
_________________
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
Eyalos
Master Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 343

PostPosted: Sat Dec 29, 2007 2:25 am    Post subject: Reply with quote

Code:
        private void ghey_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog fdlg = new OpenFileDialog();
            fdlg.Title = "Choose your executable o-o";
            fdlg.InitialDirectory = @"D:\";
            fdlg.Filter = "exe files (*.exe)|*.exe|exe files (*.exe)|*.exe";
            fdlg.FilterIndex = 2;
            fdlg.RestoreDirectory = true;
            if (fdlg.ShowDialog() == DialogResult.OK)
            {
                YourText.Text = fdlg.FileName;
            }
}


Wouldnt this be easier?
Back to top
View user's profile Send private message MSN Messenger
samuri25404
Grandmaster Cheater
Reputation: 7

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

PostPosted: Sat Dec 29, 2007 9:42 am    Post subject: Reply with quote

OpenFileDialog returns a DialogResult?

I thought it returned void. If it does return a DialogResult, then yeah, that would definately be easier.

_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
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