Maison > php教程 > php手册 > le corps du texte

C# 对文件操作自我总结

WBOY
Libérer: 2016-06-06 20:01:09
original
1363 Les gens l'ont consulté

if (System.IO.Directory.Exists(Server.MapPath(System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Day.ToString())) == false) //判断文件夹是否存在 { System.IO.Directory.CreateDirector

 if (System.IO.Directory.Exists(Server.MapPath(System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Day.ToString())) == false)  //判断文件夹是否存在
 {
     System.IO.Directory.CreateDirectory(Server.MapPath(System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Day.ToString()));  //创建文件夹
 }
 System.IO.Directory.Delete(Server.MapPath(System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Day.ToString()), true);  //删除文件夹

 

 

 if (System.IO.File.Exists(Server.MapPath(System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Day.ToString() + "/chenes.txt")))
 {//存在文件
     System.IO.File.Delete(Server.MapPath(System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Day.ToString() + "/chenes.txt"));
 }
 else
 {
     //不存在文件
     System.IO.File.CreateText(Server.MapPath(System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Day.ToString() + "/chenes.txt"));//创建该文件
 }

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!