从服务器删除文件 [英] Delete file from server

查看:100
本文介绍了从服务器删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想从asp.net中的服务器上删除文件,然后再删除,我想问一个问题,用户是否要删除它.其次,我要在删除前检查文件是否未打开

Thanx

Hi
i want to delete filefrom server in asp.net & before deleting i want to ask question whether user wants to delete it or not . Secondly i want to check file is not open before deleting

Thanx

推荐答案

是否尝试过在Google中搜索?关于文件删除,有很多代码片段.只需尝试熟悉一下 System.IO [
Tried searching in Google? There are many code snippets out there about file deletion. Just try to familiarize yourself about System.IO[^] namespace. As for the confirmation, you can do a Javascript code to display a confirmation box to the user before proceeding with the deletion.


要显示Yes/No对话框,您可以使用Ajax控件,然后从您可以使用System.IO.File.Delete("File path and name");校准服务器端代码以删除文件;

您可以将此代码放在try catch块中,如果文件已在内存中打开,则捕获异常
to display Yes/No dialog box you can use Ajax control and from that you can cal server side code to delete file with System.IO.File.Delete("File path and name");

you can place this code in try catch block and catch the exception if file is already open in memory


这篇关于从服务器删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆