http://www.koders.com/
This contains source code of some projects you can observe in free time.
http://www.box.net/
This site provides storage of up to 5GB.
http://resizepic.com/
This site is for one simple purpose, to let you resize picture.
http://www.sqlinform.com/free_online_sw.html
This site helps you in SQL Indentation.
http://telugu.changathi.com/Dictionary.aspx
Its a superb English to Telugu dictionary site.
http://en.srichaganti.net/
This site has excellent discourses on Scriptures by Brahmasri Sri Chaganti Koteswara Rao garu in Telugu.
Saturday, October 23, 2010
Friday, October 22, 2010
Delete Files created one week before
public void DeleteOldFiles()
{
DirectoryInfo di = new DirectoryInfo(MapPath("Temp//"));
FileInfo[] rgFiles = di.GetFiles("*.xml");
foreach (FileInfo fi in rgFiles)
{
string filename = fi.Name;
int index = filename.IndexOf("@");
string date = filename.Substring(0, index);
date = date.Replace("_", "/");
date = date.Replace("-", ":");
date = date.Replace("$", " ");
DateTime fromdate;
DateTime todate;
string strFromDate = date;
string strToDate = DateTime.Now.ToString();
if (DateTime.TryParse(strFromDate, out fromdate) && DateTime.TryParse(strToDate, out todate))
{
TimeSpan TS = todate - fromdate;
int daysDiff = TS.Days;
if (daysDiff > 7)
{
fi.Delete();
}
}
}
}
Here all files are stored with datetime attached to them before the filename in Temp folder.
We are trying to remove the datetime part from the respective filename so that we can delete the file if it is older than 1 week.
{
DirectoryInfo di = new DirectoryInfo(MapPath("Temp//"));
FileInfo[] rgFiles = di.GetFiles("*.xml");
foreach (FileInfo fi in rgFiles)
{
string filename = fi.Name;
int index = filename.IndexOf("@");
string date = filename.Substring(0, index);
date = date.Replace("_", "/");
date = date.Replace("-", ":");
date = date.Replace("$", " ");
DateTime fromdate;
DateTime todate;
string strFromDate = date;
string strToDate = DateTime.Now.ToString();
if (DateTime.TryParse(strFromDate, out fromdate) && DateTime.TryParse(strToDate, out todate))
{
TimeSpan TS = todate - fromdate;
int daysDiff = TS.Days;
if (daysDiff > 7)
{
fi.Delete();
}
}
}
}
Here all files are stored with datetime attached to them before the filename in Temp folder.
We are trying to remove the datetime part from the respective filename so that we can delete the file if it is older than 1 week.
Create XmlFile dynamically attaching Todays Date to its Name
xmlcontent is a string containg the xml data.It is used to generate xml content for the newly created xml file.
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlcontent);
string date = System.DateTime.Now.ToString();
date = date.Replace("/", "_");
date = date.Replace(":", "-");
date = date.Replace(" ", "$");
string filename = date + "@Test.xml";
FileInfo fi = new FileInfo(MapPath("Temp//") + filename);
FileStream fstr = fi.Create();
fstr.Flush();
fstr.Close();
string filepath = Server.MapPath("Temp//");
xmlDoc.Save(filepath + filename);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlcontent);
string date = System.DateTime.Now.ToString();
date = date.Replace("/", "_");
date = date.Replace(":", "-");
date = date.Replace(" ", "$");
string filename = date + "@Test.xml";
FileInfo fi = new FileInfo(MapPath("Temp//") + filename);
FileStream fstr = fi.Create();
fstr.Flush();
fstr.Close();
string filepath = Server.MapPath("Temp//");
xmlDoc.Save(filepath + filename);
Subscribe to:
Posts (Atom)