Click here to Skip to main content
15,889,858 members
Home / Discussions / C#
   

C#

 
QuestionHow to connect to a website and retrieve the page in C#? Pin
sheateng10-Sep-09 22:00
sheateng10-Sep-09 22:00 
AnswerRe: How to connect to a website and retrieve the page in C#? Pin
Md. Marufuzzaman10-Sep-09 22:17
professionalMd. Marufuzzaman10-Sep-09 22:17 
AnswerRe: How to connect to a website and retrieve the page in C#? Pin
vivasaayi11-Sep-09 0:53
vivasaayi11-Sep-09 0:53 
GeneralRe: How to connect to a website and retrieve the page in C#? Pin
sheateng27-Sep-09 21:43
sheateng27-Sep-09 21:43 
GeneralRe: How to connect to a website and retrieve the page in C#? Pin
vivasaayi28-Sep-09 3:52
vivasaayi28-Sep-09 3:52 
AnswerRe: How to connect to a website and retrieve the page in C#? [modified] Pin
April Fans21-Sep-09 17:09
April Fans21-Sep-09 17:09 
QuestionExcel interop issue Pin
manustone10-Sep-09 21:33
manustone10-Sep-09 21:33 
QuestionCurrent directory problem in MDI container form Pin
mutpan10-Sep-09 20:58
mutpan10-Sep-09 20:58 
Hi All,

I am creating one MDI application using C# in VS 2008. I attached the code below. I open one RTF file through the Open menu of the main form using Open dialog and loads the file in to the rich text box present in the child form. My problem is before loading the file in to the child form, the current directory points to the Debug folder of the application, but after loading the file in to the child form the current directory changes to the file directory which I opened in the child form.

For example,
before loading the file, my current directory is : "C:\Sample\Debug"
after loading the file, it changes to : "C:\ArchiveFiles"
because i opened a file from the "C:\ArchiveFiles" directory.

It is the intended behaviour of the MDI application. How do avoid changing the current directory? I want the current directoy should always point to the directory from where the EXE is running.

Is there any way to do this?

namespace WindowsFormsApplication1
{
  public partial class Form3 : Form
  {
    Form4 f4 = null;

    public Form3()
    {
      InitializeComponent();
      this.IsMdiContainer = true;
      f4 = new Form4();
      f4.MdiParent = this;      
      f4.Show();

      // Current directory here points to the debug folder
      string ctDir = System.Environment.CurrentDirectory;
      
    }

    private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
      if (DialogResult.OK == openFileDialog1.ShowDialog())
      {
        f4.OpenFile(openFileDialog1.FileName, this);        
      }

      // Current directory here points to the directory which you opened file from open dialog 
      string ctDir = System.Environment.CurrentDirectory;
      MessageBox.Show(ctDir);
    }
  }
}

public partial class Form4 : Form
  {
    public Form4()
    {
      InitializeComponent();      
    }

    
    public void OpenFile(string filename,Form  parent)
    {
      richTextBox1.LoadFile(filename);
    }
  }



Thanks in advance,
Mutpan
AnswerRe: Current directory problem in MDI container form Pin
Christian Graus10-Sep-09 21:03
protectorChristian Graus10-Sep-09 21:03 
GeneralRe: Current directory problem in MDI container form Pin
Lyon Sun11-Sep-09 1:55
Lyon Sun11-Sep-09 1:55 
AnswerRe: Current directory problem in MDI container form [modified] Pin
April Fans21-Sep-09 17:06
April Fans21-Sep-09 17:06 
Questionaccess font colour paterns in ToolStripCombo box Along with name Pin
santosh_anu10-Sep-09 20:52
santosh_anu10-Sep-09 20:52 
AnswerRe: access font colour paterns in ToolStripCombo box Along with name Pin
Henry Minute11-Sep-09 0:05
Henry Minute11-Sep-09 0:05 
GeneralRe: access font colour paterns in ToolStripCombo box Along with name Pin
santosh_anu11-Sep-09 7:09
santosh_anu11-Sep-09 7:09 
GeneralRe: access font colour paterns in ToolStripCombo box Along with name Pin
Henry Minute11-Sep-09 9:09
Henry Minute11-Sep-09 9:09 
AnswerRe: access font colour paterns in ToolStripCombo box Along with name Pin
April Fans21-Sep-09 17:15
April Fans21-Sep-09 17:15 
GeneralRe: access font colour paterns in ToolStripCombo box Along with name Pin
santosh_anu21-Sep-09 21:12
santosh_anu21-Sep-09 21:12 
QuestionHow to execute SSIS package from windows service Pin
Rajesh Koriya10-Sep-09 19:51
Rajesh Koriya10-Sep-09 19:51 
AnswerRe: How to execute SSIS package from windows service Pin
Kuthuparakkal21-Aug-12 17:44
Kuthuparakkal21-Aug-12 17:44 
QuestionAccessing bytes in a video as it is playing in windows media player Pin
FoxholeNorman10-Sep-09 17:28
FoxholeNorman10-Sep-09 17:28 
AnswerRe: Accessing bytes in a video as it is playing in windows media player Pin
Christian Graus10-Sep-09 17:52
protectorChristian Graus10-Sep-09 17:52 
GeneralRe: Accessing bytes in a video as it is playing in windows media player Pin
FoxholeNorman11-Sep-09 2:38
FoxholeNorman11-Sep-09 2:38 
QuestionLighten area of a image Pin
hardsoft10-Sep-09 11:35
hardsoft10-Sep-09 11:35 
AnswerRe: Lighten area of a image Pin
Christian Graus10-Sep-09 11:40
protectorChristian Graus10-Sep-09 11:40 
AnswerRe: Lighten area of a image Pin
carlecomm23-Sep-09 15:01
carlecomm23-Sep-09 15:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.