Last post Jun 05, 2019 08:29 PM by ryanbesko
Apr 19, 2019 01:14 PM|baldwinjohn|LINK
I have an asp.net web application where I have a button that when clicked creates several reports and then merges them together into one pdf file using itextsharp.dll in c# code behind. Currently I have the folder destination hard-coded in the application.
I need to update it so that when the user clicks on the button a file dialog box comes up that allows them to choose the folder they want to save the file to (just need to choose the folder, not select a file etc). I tried the Fileupload feature but that requires
you to select a file. In windows forms I used OpenDialog but that doesn't seem to be available in a web application. What do I need to do to accomplish this task?
Apr 22, 2019 02:12 AM|Wei Zhang|LINK
According to your description,I couldn't understand your requirement clearly.Do you want to update the folder in the server or you just want that when users enter the button,the folder could be downloaded in users' local
machine? In fact , fileupload control is used for submit folder from local side to server.It seems not suitable for your requirement.
If you just want to use fileupload control to submit a folder, you could save multiply files in folder as long as you add attribution setting in this control.You could see as below:
in .net 4.5 and higher:
<asp:FileUpload ID="fileImages" AllowMultiple="true" runat="server" />
.NET 4 and below
<asp:FileUpload ID="fileImages" Multiple="Multiple" runat="server" />
Here is the link, I hope it could help you.
Apr 22, 2019 12:15 PM|baldwinjohn|LINK
I don't need to upload any files. Just choose a folder location. File upload forces you to choose an existing file. Is there a way to use FileBrowserDialog in asp.net?
Apr 23, 2019 03:16 AM|Wei Zhang|LINK
In asp.net ,we couldn't just directly get a folder by using anything like FileBrowserDialog.
Since the desktop application is running on the user's local computer, FileDialog can directly manipulate the local folder and then read all the files in a folder through the file api. But the web application is different. It can't read the contents
of the user folder through the file api because the code of the web application is running on the server side, it can only operate the folder of the server and cannot manipulate the files on the user's computer. folder.
Else neither the HTML tag nor the javascrpt provides an API to manipulate a folder. The web page can only manipulate files and cannot manipulate folders.
Jun 05, 2019 03:46 PM|stilmas|LINK
Jun 05, 2019 08:29 PM|ryanbesko|LINK
Is the document just opening instead of asking to save? How the browser treats specific file types behave depends on the user's browser selections (always ask when downloading this type of file..., etc). You can add
Content-Disposition: attachment; filename="MyPdf.pdf"
to your download code but if the user has already told their browser to just open a specific file type you can't do anything about it.