[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Rajika Somasiri

2/9/2004 8:12:00 AM

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;

}

}






2 Answers

Anusha Nanayakkara

2/23/2004 8:45:00 AM

0

Hi,

"name" may be use as a keyword. You better try with strName insted of "name" variable.

Anusha

>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;
>
> }
>
> }
>
>
>
>
>
>
>

___
Newsgroups brought to you courtesy of www.dotnetjohn.com

Anusha Nanayakkara

2/23/2004 9:13:00 AM

0

Hi
Use "strName" insted of "name" variable and try weather it's working

Anusha.

>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;
>
> }
>
> }
>
>
>
>
>
>
>

___
Newsgroups brought to you courtesy of www.dotnetjohn.com