G
gordon
Hi,
I am trying to create a reference to an external file to write to using
stream writer and a value that is created in a for. Basically the value
that a user will create will be the name of the form.
The code below show my dilemma. The line "using (StreamWriter sw = new
StreamWriter(@"c:\{0}.txt",fmtname)) " does not work as the arguement
"fmtname" is not valid in that context. Do I need to use some string
builder routine prior to this to make the sw accept the input value as its
arguement??
private void btnOK_Click(object sender, System.EventArgs e)
{
if (int.Parse(tbStart.Text)>int.Parse(tbEnd.Text))
MessageBox.Show("The value in the End box is less than the Start");
double Vend =System.Convert.ToDouble(tbEnd.Text);
double Interval=System.Convert.ToDouble(tbInterval.Text);
double Start=System.Convert.ToDouble(tbStart.Text);
if ((Vend-Start) %Interval>0 )
MessageBox.Show("The interval is not a readily divisible into the End
value");
string fmtname=tbName.Text.ToString();
string fmtstart=tbStart.Text.ToString();
string fmtend=tbEnd.Text.ToString();
using (StreamWriter sw = new StreamWriter(@"c:\{0}.txt",fmtname))
{
sw.WriteLine("Proc format; ");
sw.WriteLine("value {0}",fmtname) ;
sw.WriteLine("{0} - {1} = '{0} to {1}'",fmtstart, fmtend);
sw.WriteLine("; ");
sw.WriteLine("Run;");
MessageBox.Show(@"File written to c:\{0}.txt",fmtname);
}
}
thanks
Doug
I am trying to create a reference to an external file to write to using
stream writer and a value that is created in a for. Basically the value
that a user will create will be the name of the form.
The code below show my dilemma. The line "using (StreamWriter sw = new
StreamWriter(@"c:\{0}.txt",fmtname)) " does not work as the arguement
"fmtname" is not valid in that context. Do I need to use some string
builder routine prior to this to make the sw accept the input value as its
arguement??
private void btnOK_Click(object sender, System.EventArgs e)
{
if (int.Parse(tbStart.Text)>int.Parse(tbEnd.Text))
MessageBox.Show("The value in the End box is less than the Start");
double Vend =System.Convert.ToDouble(tbEnd.Text);
double Interval=System.Convert.ToDouble(tbInterval.Text);
double Start=System.Convert.ToDouble(tbStart.Text);
if ((Vend-Start) %Interval>0 )
MessageBox.Show("The interval is not a readily divisible into the End
value");
string fmtname=tbName.Text.ToString();
string fmtstart=tbStart.Text.ToString();
string fmtend=tbEnd.Text.ToString();
using (StreamWriter sw = new StreamWriter(@"c:\{0}.txt",fmtname))
{
sw.WriteLine("Proc format; ");
sw.WriteLine("value {0}",fmtname) ;
sw.WriteLine("{0} - {1} = '{0} to {1}'",fmtstart, fmtend);
sw.WriteLine("; ");
sw.WriteLine("Run;");
MessageBox.Show(@"File written to c:\{0}.txt",fmtname);
}
}
thanks
Doug