浏览保存位置目录 [英] Browse Directories for save location
问题描述
我需要code,这将允许用户执行以下操作:
-
选择一个浏览按钮,然后选择文件夹,他们希望保存一次exe文件的文件在程序运行结束
-
显示文件夹位置在文本框中选择它旁边的用户
基本上,这是一个保存对话框,但由于这是一个Web应用程序,而不是一个网页表单我不能使用对话框。
下面是code我到目前为止,我想它不是正确的,请帮助我!
保护小组Browse_Click(BYVAL发件人为对象,BYVAL E上System.EventArgs)把手Browse.Click
昏暗的文件路径作为字符串=(C:\\用户\\公用\\文件)
昏暗的TargetFile作为System.IO.FileInfo =新System.IO.FileInfo(文件路径) 如果targetFile.Exists然后
Response.Clear()
Response.AddHeader(内容处置,附件;文件名=+ targetFile.Name)
Response.AddHeader(内容长度,targetFile.Length.ToString)
Response.ContentType =应用程序/八位字节流
Response.WriteFile(targetFile.FullName)
万一
结束小组
正如他们所说,你不能做的正是你想要由于安全的。但是你可以依靠一个asp.net文件上传控制。
I need code that will allow the user to do the following:
Select a browse button and choose the folder they want to save a file once the exe file at the end of the program runs
Display the folder location the user selected in the textbox next to it
Basically this is a save dialog box but since this is a web application and not a web form I can not use the dialog boxes.
Here is the code I have so far, I am thinking its not right so please help me with this!
Protected Sub Browse_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Browse.Click
Dim FilePath As String = ("C:\Users\Public\Documents")
Dim targetFile As System.IO.FileInfo = New System.IO.FileInfo(FilePath)
If targetFile.Exists Then
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" + targetFile.Name)
Response.AddHeader("Content-Length", targetFile.Length.ToString)
Response.ContentType = "application/octet-stream"
Response.WriteFile(targetFile.FullName)
End If
End Sub
As they said, you can't do exactly what you want to due to security. But you can rely on a asp.net file upload control.
这篇关于浏览保存位置目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!