private void virfile()
{
if (!Directory.Exists(Server.MapPath("download/")))
Directory.CreateDirectory(Server.MapPath("download/"));
string filpath = Server.MapPath("download/" + "data.txt");
string filedir = filpath.Substring(0, filpath.LastIndexOf('.'));
string fileext = System.IO.Path.GetExtension(filpath);
if (!File.Exists(filpath))
{
File.AppendAllText(filpath, "file downloaded on : " + DateTime.Now.ToString() + "\r\n");
}
else
{
int i = 1;
while (true)
{
filpath = filedir + "(" + i + ")" + fileext;
if (!File.Exists(filpath))
{
File.AppendAllText(filpath, "file downloaded on : " + DateTime.Now.ToString() + "\r\n");
break;
}
i++;
}
}
}
No comments:
Post a Comment