只读文件夹问题 [英] ReadOnly Folder Problem
本文介绍了只读文件夹问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个问题,我想通过位于服务器只读文件夹下的代码删除文件.我需要临时更改文件夹设置,这样我才能删除其中的文件.
还是他们可以通过其他任何方式实现这一目标?
谢谢.
Hi All,
I have a problem, i want to delete a file through code which is located under read only folder at server. i need to change the folder setting temporarily which allows me to delete the file in it.
Or is their any other way i can achieve this?
Thank you.
推荐答案
请参见 ^ ].
string filePath =Server.MapPath("file.txt");
System.IO.File.SetAttributes(filePath,System.IO.File.GetAttributes(filePath) ^ System.IO.FileAttributes.ReadOnly);
System.IO.File.Delete(filePath);
这篇关于只读文件夹问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文