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);
Related
We use an industry standard file (PDX) that is basically a zip archive file with the extension changed. I want to allow the user to first select a .pdx file and then allow them to select a file within the archive. I found this answer that shows a very clever way to achieve this using the OpenFileDialog. It works great if the archive has the .zip extension. The problem is when the extension of the archive file is changed to .pdx then the open file dialog will not show the contents of the .pdx file.
Is there a way to achieve this functionality with the OpenFileDialog? I do not want to create my own dialog if there is a simple solution.
Is it possible to copy the PDX file to a temporary folder? Then change the extension to name.pdx.zip, when the user clicks select file, and after that immediately open the zip in the temporary folder?
user clicks open file (the .pdx file), (so the selection window closes)
the program copies the PDX file to a temp folder
change the extension of the new file to name.pdx.zip (inside the temporary folder).
automatically open another file select window into the zip file
I hope I could help.
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 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.
So I'm using WebClient to upload a file to a server. It works great except for one problem. If the file is opened by another program then it will not upload. For instance, if it's a word document that's been saved but is still opened by word then it fails to upload. Is there a way to force it to read whatever is there and upload it?
If i understand your question right then you can use this solution to test if the file is open and then close it if it is. It's a useful helper class i've used in the past.
https://stackoverflow.com/a/1247326/4612655