R
Rajika Somasiri
In the following code "fname" is a variable for a file name and "name" is a
string variable. But when I use fname it does not contain the ".txt" part.
Therefore I cannot create the file.
private StreamWriter StartTracking(string name)
{
try
{
if(!Directory.Exists("Info"))
Directory.CreateDirectory("Info");
string fname = "Info\\" + DateTime.Now.ToString("ddMMyyHHmm")+ name+ ".txt";
infowriter = new StreamWriter(new FileStream(fname,
FileMode.OpenOrCreate,FileAccess.Write));
return infowriter;
}
catch(Exception ev)
{
string msg = ev.Message;
return null;
}
}
string variable. But when I use fname it does not contain the ".txt" part.
Therefore I cannot create the file.
private StreamWriter StartTracking(string name)
{
try
{
if(!Directory.Exists("Info"))
Directory.CreateDirectory("Info");
string fname = "Info\\" + DateTime.Now.ToString("ddMMyyHHmm")+ name+ ".txt";
infowriter = new StreamWriter(new FileStream(fname,
FileMode.OpenOrCreate,FileAccess.Write));
return infowriter;
}
catch(Exception ev)
{
string msg = ev.Message;
return null;
}
}