| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2015 人关注过本帖
标题:如何将服务器中删除从客户端上传到服务器端的文件???
只看楼主 加入收藏
foshan
Rank: 1
等 级:新手上路
威 望:2
帖 子:605
专家分:0
注 册:2006-3-1
结帖率:100%
收藏
 问题点数:0 回复次数:7 
如何将服务器中删除从客户端上传到服务器端的文件???
将文件从客户端上传到服务器后,觉得上传错文件了,如何其从服务器上删除啊???谢谢!
搜索更多相关主题的帖子: 服务器 客户端 文件 删除 
2007-03-14 16:52
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 
deleteFile(path)

[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2007-03-14 16:53
mldark
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2006-9-5
收藏
得分:0 
你不会进服务器里面操作?
2007-03-14 17:27
foshan
Rank: 1
等 级:新手上路
威 望:2
帖 子:605
专家分:0
注 册:2006-3-1
收藏
得分:0 

在客户端向服务器端操作删除文件,出错,如何解决啊?谢谢!

Server Error in '/showbaobiao' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>


我是2.0超级菜鸟,请多多教导!
2007-03-14 17:41
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
应该是路径不对吧...删除时,为了不出错,最好先判断一下那个文件是否存在..如果存在再删除..

飘过~~
2007-03-14 17:45
foshan
Rank: 1
等 级:新手上路
威 望:2
帖 子:605
专家分:0
注 册:2006-3-1
收藏
得分:0 
代码如下,但就出现以上的错误提示,如何解决啊???
protected void Button3_Click(object sender, EventArgs e)
{
//先找到文件所在路径,然后判断文件存在否,最后删除文件
string Url="/files/2006年/工地检查通知及通报/07年1月份实情汇报.doc";
string fileUrl = Server.MapPath(".") + Url;
if (File.Exists(fileUrl))
{ File.Delete(fileUrl); } //删除文件
else
{ Response.Write("<script>alert('文件不存在!')</script>"); }
}

我是2.0超级菜鸟,请多多教导!
2007-03-14 17:51
foshan
Rank: 1
等 级:新手上路
威 望:2
帖 子:605
专家分:0
注 册:2006-3-1
收藏
得分:0 

Server Error in '/showbaobiao' Application.
--------------------------------------------------------------------------------

Access to the path 'e:\myweb\showbaobiao\files\2006年\工地检查通知及通报\07年1月份实情汇报.doc' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 'e:\myweb\showbaobiao\files\2006年\工地检查通知及通报\07年1月份实情汇报.doc' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:


Line 224: string fileUrl = Server.MapPath(".") + Url;
Line 225: if (File.Exists(fileUrl))
Line 226: { File.Delete(fileUrl); } //删除文件
Line 227: else
Line 228: { Response.Write("<script>alert('文件不存在!')</script>"); }

Source File: e:\myweb\showbaobiao\Default2.aspx.cs Line: 226

Stack Trace:


[UnauthorizedAccessException: Access to the path 'e:\myweb\showbaobiao\files\2006年\工地检查通知及通报\07年1月份实情汇报.doc' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2014147
System.IO.File.Delete(String path) +157
Default2.Button3_Click(Object sender, EventArgs e) in e:\myweb\showbaobiao\Default2.aspx.cs:226
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42


我是2.0超级菜鸟,请多多教导!
2007-03-14 18:04
foshan
Rank: 1
等 级:新手上路
威 望:2
帖 子:605
专家分:0
注 册:2006-3-1
收藏
得分:0 
应该是对目录的访问没有权限。

首先修改文件夹属性:

资源管理器 - > 工具 - > 文件夹选项 - > 显示 - > 把简单文件共享的选择去掉(默认是打钩的)

选择上传文件夹 - > 右键 - > 安全 - > 把everyone用户的读写权限都加上。

我是2.0超级菜鸟,请多多教导!
2007-03-15 09:47
快速回复:如何将服务器中删除从客户端上传到服务器端的文件???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021678 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved