如何在asp.net中存在文件时显示警报消息(浏览新文件时)

编程入门 行业动态 更新时间:2024-10-11 07:32:30
本文介绍了如何在asp中存在文件时显示警报消息(浏览新文件时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 如何在asp中获取文件(浏览新文件时)时显示警报消息. 任何建议...

Hello All, How To Show alert message when file is already taken(When Browsing for a new file) in asp.. Any Suggestions...

推荐答案

/*To get user uploaded file name*/ UploadedFile filename = rauPIAMSpeRateLetter.UploadedFiles[0]; strGetFileName = filename.GetName(); /*Path to save user uploaded file(Store your path in hidden field)*/ string strFileName = hdfUploadPath.Value + strGetFileName; /*Check for existence of file if not exists then I am saving else I am giving message to user*/ if (!File.Exists(strFileName)) { filename.SaveAs(strFileName, true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Error", "alert('File already exist or rename file then upload');", true); return; }

文件存在:System.IO.File.Exists. 显示:有很多方法可用;我建议这样做: File exists: System.IO.File.Exists. Showing: many methods are available; I would recommend this: <p><% some_C#_expression_calculating_the_message_text %></p>

请注意,现有文件"只能表示HTTP服务器所在主机的文件系统中的某些文件.因此,您只能计算服务器部分的存在,这使显示"变得容易:无论如何,内容都将在HTTP响应中返回.

—SA

Note that the by existing file you can only mean some file in the file system of the host where the HTTP server works. Consequently, you can only calculate existence on the server part, which makes the "showing" easy: the content is returned in the HTTP response anyway.

—SA

更多推荐

如何在asp.net中存在文件时显示警报消息(浏览新文件时)

本文发布于:2023-11-27 16:10:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638692.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   新文件   消息   文件   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!