how to get file on asp.net form so that user can download it?
suppose i have created one excel file and i want to upload it on form so that user can download it, fill the details when they are offline.
You can use
Response.AddHeader("content-disposition", "attachment; filename=test.txt");
Response.WriteFile(#"test.txt");
Response.End();
Otherwise if it's a specific file you can use a normal Download Meand point it to the files location.
Use the fileupload component. I would store the file locally on the server and then display a list of the uploaded files.the list would be a list of hyperlinkswhich you can link directly to the uploaded files so when the user clicks on one, the file download begins automatically using the standard browser behavior.
Place the file in one of your directories under the application root folder and then you can simply place an anchor tag to let user download the file, like
abc
Related
I need something like the FileUpload control in asp.net that will allow the user to browse for a folder and enter a file name of a new file to upload.
From what I've seen FileUpload requires a file to be selected. It seems that html input type="file" has the same requirement.
Thanks!
Selecting an entire folder is not possible in FileUploadControl as it is meant for a single file. Although you can have a Multi File Selection. Multiple File Upload User Control
C# has build-in FTPrequest class where you can create folders, upload files, delete files etc.
If you want to upload folders from a webpage, you cannot use this technology in the browser, then you will have to use a rich-client such as Java, Flash or similar plugin.
If you can provide the users with a Windows or Mac client, you can use C# (either .NET or Mono) for the FTP transfer.
ZIP files arent a problem for ASP.net nor C#, but you still only upload 1 file (zip-archive) and then its up to the server to unzip it using eg. C#. Look at 7-Zip which is opensource, then you might get some ideas too.
You could also just try and use the build-in lib for it (compression):
http://www.eggheadcafe.com/community/csharp/2/10050636/how-to-compress-and-decompress-file-in-c.aspx
or try this link...
http://www.aurigma.com/docs/iu7/uploading-folders-in-aspnet.htm
The user uploads an image which I name as logo.png and I save it in a folder. The user can upload new image anytime he wants. I have 7 files in the same folder.
I get that image via API. At the moment, I download the image every time I run my program. What I need is a flag to know if the user uploaded a new image than the one I already downloaded. If not - don't download the file. if yes - download it. How can I find out if the user uploaded a new file?
I know that I can use a db field for this, but is there a property of the Image class, or the FileSystemInfo class which can tell me this?
FileSystemInfo has LastWriteTime property which Gets or sets the time when the current file or directory was last written to.
refer this link : http://msdn.microsoft.com/en-us/library/system.io.filesysteminfo.lastwritetime(v=vs.110).aspx
How do I open a PDF file List in dialog box in a new Window in an ASP.NET application ?
I want list of pdf file which is stored in folder in my application and then select any of pdf and save in logged user's particular folder.
Since you want to display a list of pdf files stored in a folder on the server side you will need to render the list to a page in some format that makes sense. You may open that up as a dialog (perhaps using something like jquery ui) but it wouldn't be necessary.
Next to each file you could have a button that indicates the action you are after, say 'Copy'.
This would then send the id/name of the relevant file to the server and the server code could copy the file to some other location on the server that you refer to as the users folder.
However, if you want to download the file to the user's machine that is something else and you will find many answer here on SO about that.
I am dynamically generating html file. It is formated with Css and Images. I am looking for code which should able to execute on button click, and ask the location for saving file. also it should download concern resource files which has referenced in html file. What code i have to do ? Can i use WebClient for the same ?
There is no "Save As" dialog in ASP.NET. Since it is running in a browser. You have no access to the user's file system, including the Save As dialog.
But you can send the user a file, as an attachment, most browsers will display a dialog asking the user whether to save the file or open it. Maybe the user will choose to save it.
Response.ContentType = "application/octet-stream" (or content type of your file).
Response.AppendHeader("content-disposition", "attachment;filename=" & strFileName)
You could create a situation where you can use WebClient if you make your file available through a uri, see this post.
Yes, you can use WebClient. Option is to use HttpRequest and HttpResponse.
I want to browse to folder on button click and select a file in that folder. When user selects a particular file. I want to retrieve the folder path and size of that file ?
How can i do that in asp.net with c#
BTW i'm using vs2008.
Please help me
Thanks in anticipation
Why not use the FileUpload control instead of a Button? http://asp.net-tutorials.com/controls/file-upload-control/
Using FileUpload control, it will accept file uploads from users and is extremely easy. With the FileUpload control, it can be done with a small amount of lines of code, as you will see in the following example. However, please notice that there are security concerns to to consider when accepting files from users!
Use the FileUpload control to let user browse to the file, select it and upload it. Unfortunately, there is no way to retrieve the file size until the file is uploaded (without using Silverlight or other third-party browser components). Once the file is uploaded, you can retrieve file size via the ContentLength property.