I am using c# to save info in MS Access DB,And the form is using file upload control.And I could like to save the attached document of file control in specvific folder of the project.Can any one help me how can I do it.
FieUpload.SaveAs function is the one you looking for.
FileUpload1.SaveAs(savePath);
Also, check Environment.SpecialFolder library to find a suitable default folder as you like.
Related
I can't seem to find any examples of downloading multiple files from a URL.
I have a URL lets say www.example.com/Document and I want to download all the files in that URL is that possible? or do I need to provide the name of each file in that URL? All the files would download to a folder specified here in the code.
Any examples of this would be great, this would be done by clicking a Download button in WPF.
The way I did this was to create a ZIP file and have all the files in there. You can either pre create a ZIP file and download or you can create the ZIP file as it downloads. I had to write my own software to do that but it does work.
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
I am using Cefsharp's DownloadHandler to implement a download functionality in WinForms. I am able to cancel the downloading file using callback.Cancel() method in OnDownloadUpdated() method. The problem is that the partially downloaded file is not deleted. I am storing the downloaded files in the "Downloads" folder.
You can just remove the file by yourself after canceling the download. One of the parameters in the OnDownloadUpdated method is downloadItem which contains the full path of the file.
Something like this:
System.IO.File.Delete(downloadItem.FullPath);
I have an application in c#.net in which I have embeded the SWF file in SWFObject from COM Object.
Now after installation, the original SWF file also available in the application root directory. So from that place(application root directory) anyone can access that file. But I want to restrict that file from being opened.
axShockwaveFlash1.Movie = Directory.GetCurrentDirectory() + "\\XYZ.swf";
I did something like this.
So how can I restrict that file in application root directory such that only from my application I can access it..??
You can embed the file into a dll or exe file and play it from there. this way it is not (as a seperate file) in the file system at all.
For details see How to embed and access resources by using Visual C#.
You could save the swf file binary data as static bytes in your code and statically load them and convert back to an swf file. The conversion might take a little while but it only occurs once as you open the program.
Edit:
But k3b's answer is better.
Permissions are based on users, not applications, so the short answer is you can't. However, you can build your own application-specific authentication pretty easily. Have your SWF require specific FlashVars to be set in order to move beyond frame 1. People can still decompile your SWF but this will at least stop most people. Another option is to try to store the data within you binary somehow and load the SWF using a byte-array, see this post for one attempt at that.
I need to create a Web page that manages a shared folder, which means you can upload and download files, these preferably pdf and a certain size. This shared folder has security therefore must be accessed in any way with user key.
I need to know if there is some sort or some method easy to perform in ASP C#, give me options to view folders and their files created and upload new in a new folder.
I would appreciate your help and advice in order to make this website.
Use System.IO.DirectoryInfo and System.IO.FileInfo to work with a file system from .NET.
Using 'System.IO.FileStream' in one way to create new files from binary data (stream or byte[])
Easy way would be to use a third party control like FileUltimate
Or you can bulid your own custom file manager by using utility classes in System.IO and HttpResponse class for file streaming