EDN Admin
Well-known member
I select a text file but i need to pass only the path and not the file name.
This is the loadtoolstripmenuitem event:
<pre class="prettyprint private void loadCoordinatesToolStripMenuItem_Click(object sender, EventArgs e)
{
file1 = "";
DialogResult result1;
result1 = new DialogResult();
openFileDialog1.Title = "Select a text file to load";
openFileDialog1.InitialDirectory = "c:\";
openFileDialog1.FileName = null;
openFileDialog1.Filter = "Text File|*.txt";
openFileDialog1.FilterIndex = 1;
openFileDialog1.RestoreDirectory = true;
result1 = openFileDialog1.ShowDialog();
if (result1 == DialogResult.OK)
{
file1 = openFileDialog1.FileName;
wireObject1.Load(file1);
textBox3.Enabled = false;
trackBar1.Enabled = true;
}
if (result1 == DialogResult.Cancel)
{
}
}[/code]
<br/>
The wireObject1.Load function is:
<pre class="prettyprint public void Load( string path)
{
string fn = path + "\" + wo_name;
OptionsFile setting_file = new OptionsFile(fn);
woc.Point_X = setting_file.GetListFloatKey("Coordinates_X");
woc.Point_Y = setting_file.GetListFloatKey("Coordinates_Y");
connectionStart = setting_file.GetListIntKey("ConnectionStart");
connectionEnd = setting_file.GetListIntKey("ConnectionEnd");
}[/code]
I get the path name and in wireObject class i did that it must have instance with a string name.
Then i build the file name alone in the Load function.
This is the wireObject class constructor:
<pre class="prettyprint public WireObject( string name )
{
wo_name = name;[/code]
So lets say i did an instance of the WireObject like: wo1 = new WireObject("hello");
So in the Load function i have the hello name and i suppose to get the path and then build the file name.
For example i have a file hello.txt in d:
So in Load path is d: and wo_name is hello.txt
But in Form1 in the openFileDialog i dont know how to get only the path.
<hr class="sig danieli
View the full article
This is the loadtoolstripmenuitem event:
<pre class="prettyprint private void loadCoordinatesToolStripMenuItem_Click(object sender, EventArgs e)
{
file1 = "";
DialogResult result1;
result1 = new DialogResult();
openFileDialog1.Title = "Select a text file to load";
openFileDialog1.InitialDirectory = "c:\";
openFileDialog1.FileName = null;
openFileDialog1.Filter = "Text File|*.txt";
openFileDialog1.FilterIndex = 1;
openFileDialog1.RestoreDirectory = true;
result1 = openFileDialog1.ShowDialog();
if (result1 == DialogResult.OK)
{
file1 = openFileDialog1.FileName;
wireObject1.Load(file1);
textBox3.Enabled = false;
trackBar1.Enabled = true;
}
if (result1 == DialogResult.Cancel)
{
}
}[/code]
<br/>
The wireObject1.Load function is:
<pre class="prettyprint public void Load( string path)
{
string fn = path + "\" + wo_name;
OptionsFile setting_file = new OptionsFile(fn);
woc.Point_X = setting_file.GetListFloatKey("Coordinates_X");
woc.Point_Y = setting_file.GetListFloatKey("Coordinates_Y");
connectionStart = setting_file.GetListIntKey("ConnectionStart");
connectionEnd = setting_file.GetListIntKey("ConnectionEnd");
}[/code]
I get the path name and in wireObject class i did that it must have instance with a string name.
Then i build the file name alone in the Load function.
This is the wireObject class constructor:
<pre class="prettyprint public WireObject( string name )
{
wo_name = name;[/code]
So lets say i did an instance of the WireObject like: wo1 = new WireObject("hello");
So in the Load function i have the hello name and i suppose to get the path and then build the file name.
For example i have a file hello.txt in d:
So in Load path is d: and wo_name is hello.txt
But in Form1 in the openFileDialog i dont know how to get only the path.
<hr class="sig danieli
View the full article