i need to create file date wise ..though folder is CREATING NOW .. but need to put date wise file in run time folder

String logfile = t.FileName.ToString() + "/" + LoginID + "DateTime.ToString("yyyyMMdd").txt";

          t.FileName = logfile;

LoginID is value taken from database ..and changes folder on fly ..but need to create text file .. I am stucked here ..Any Help ???????

Can You post the entire code...

By the way try this:

String logfile = t.FileName.ToString() + "/" + LoginID + DateTime.ToString("yyyyMMdd")+".txt";

on following line it gives error
logfile = logfile + "/" + LoginID + "/" + System.DateTime.ToString("yyyyMMdd") + ".txt";
Compiler Error Message: CS0120: An object reference is required for the non-static field, method, or property 'System.DateTime.ToString(string)'

Modify as:

String logfile = t.FileName.ToString() + "/" + LoginID + DateTime.Now.ToString("yyyyMMdd")+".txt";

or,

String logfile = t.FileName.ToString() + "/" + LoginID + DateTime.Now.ToShortDateString()+".txt";

i mentioned in nlog.config in both ways

1.<target name="file" xsi:type="File" filename="EnwayLog\${date:format=yyMMdd}\${shortdate}.txt"/>
2.<target name="file" xsi:type="File" filename="EnwayLog/${date:format=yyMMdd}/${shortdate}.txt"/>

but its not creating in any way any helpppppppppp

yesterday i write in nlog.config as following

<target name="file" xsi:type="File" filename="EnwayLog\${shortdate}\${shortdate}.txt" />

and it created folder 2013-04-15 and then date file and write logging in it

Now today i open My project run it (Visual studio 2008) ..it not creating today's folder ..

can u help me if not any problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.