I want to download a file to a specific folder. I'm using WebClient.DownloadFile, but what I would like is to let the user select where this file would be saved, not just download it into any folder.
How can I do this?
The folder that the user would download the file to would depend on their browser, and system settings.
All you can do is provide the file to download, and it would be up to them (and their browser) to select a local folder (on their system).
If you want to control that process, you would have to use an embedded plugin like Java, Silverlight, Flash, etc.
If you are using Windows Forms, you can use the SaveFileDialog class to allow the users to pick a file name, and then pass that name to the second parameter of WebClient.DownloadFile.
Related
I've a .Net/C# Windows application which can create text/pdf files. My requirement is to make these files accessible via http links for another internal application inside my organization. The internal application only accepts http links (ftp and others are not supported).
I know this can be done manually by placing these files in an IIS server. I would like to know whether there is any easy way to do this programmatically? Once the file is created locally in my application, I should have a http link to access the file.
I'm not sure if I understand your need correctly. You can point it out when anything wrong.
Assuming that the application create pdf files in a folder named PDFile. On IIS, you can add a site and set it physical path to PDFile folder. If you enable Directory Browsing, you can see all files when enter the url of this site in browser like this:
When you want to access these file from an external machine, just enter the url http://serverIP:port/PDF file name for example http://xxx.xxx.xxx.xxx:80/mycustomefile.pdf. No need to set anything programmatically.
I am working on one MVC web application project, which require one field called folder selection just like FolderBrowserDialog in windows application.
Help me to find that FolderBrowserDialog for web application. Is there any solution for folder selection in MVC??
Short answer is no. You can use a to select a file, but modern browsers will not send a path for security reasons (and your browser does not have access to paths on the server)
There is no such control (except using ActiveX Control or Java Applets), so don't waste your time to look for it and you can not get any folder path(on the client machine) with JavaScript due to security reasons.
Why don't you just allow the user to download the file and user will select the folder where he wants that file to be saved or else it will get saved in default folder of the browser.
Hope it helps, thanks.
In my project, I have a fileupload control for user to upload their document and I want to provide a link to user to open their files.
steps:
after user upload a file, my web will create a link for it
when user click on that link, the container folder of that file will open.
For example, a file which its path is C:\Users\John\Downloads\jpg\a.jpg uploaded to the fileupload control. when user click on the link of that file, a folder C:\Users\John\Downloads\jpg will be opened.
To get the file path:
string filePath = FileUpload1.PostedFile.FileName; // file name with path.
So, how can I open a folder in client PC by C#?
For security reasons, browsers do not expose the local filesystem to the Javascript sandbox. What you're asking is not possible with Javascript or any other common browser technology that does not require a client install (like Flash or ActiveX). You definitely cannot get it in c# which runs on the server and has no knowledge of the client's filesystem.
I know when uploading files for security reasons the browser will not get directory of file when using a file upload control. But what I am looking for is for the local network user to select a file in a network drive and capture the path and file name but not upload that file. this is just to store the file they select in a table. Is there a way of doing this? some sort of work around? the only thing I've thought of is putting a textbox and having the user copy/paste the file path but is there an easier method? again not uploading the file just capturing what file and location the local network user wants to use.
It can't be done using the File upload control (html input element). You have to use a plugin like (possibly) Flash or a custom ActiveX control.
What you are looking for is not possible using standard web technologies (html, css, js).
I need to Copy the files from desktop and Paste it in Web application created by asp.net with c#.
If the user copy any files from esktop, and paste the file in my webapplication output(i,e i run the application, the user enter using their login and paste some files.
then my application get the file and save it.
so, how can i get the file while user paste?
This is urgent.
Thanks and regards,
Pooja
So I assume you allow user to access your application folder via network sharing, then you met need to monitor that folder so after new file added you can get them, please check this: http://www.techrepublic.com/article/use-the-net-filesystemwatcher-object-to-monitor-directory-changes-in-c/6165137
and hope it helps.
But why not you implement some upload function?