Change dialog settings on a webbrowser's savedialog - c#

I am working with a webbrowser. When I call the ShowSaveAsDialog, I want to be able to choose a default filename and a default extension type for it. How can I do this? I do not see any way of modifying the dialog box that pops up there.
If I cannot do that, how can I save the contents of my webbrowser to a file of my choice (htm/html file for example)?

Related

Is it possible to lock top and left hand navigation in OpenFileDialog box in C#?

I am having difficulty in customizing OpenFileDialog box, I want to allow people to select files that are in the same directory from the currently open folders using the OpenFileDialog. I don't want the OpenFileDialog to be able to select stuff outside of the program's current directory
Due to some reason i am not able to post image, what i meant is to lock Top navigation and Side Navigation option in OpenFileDialog box
As far as I know you can only add elements to the standard file dialogs (using some esoteric api calls), but there is no way to remove elements. Your best bet, if you really need this functionality, is to implement your own custom Open File Dialog with the specific business rules you need.
Here are some details on how to do some limited customizations.
http://msdn.microsoft.com/en-us/magazine/cc300434.aspx
http://www.codeproject.com/Articles/16276/Customizing-OpenFileDialog-in-NET
Customizing OpenFileDialog
Customizing a default dialog might be the hard way to go.
Why not just show a listbox containing the names of the files you wish the user to be able to select?
I don't know how to lock the dialog. But if the requirement is simply to present a list of files from which they select one. Then why not just read the file list yourself and present them in a custom dialog for selection?
If you want you can then spend some time making the dialog look like the system one.

Download Dialog Box

How to change Design of Download Dialog Box in C#.Net?
How can I slove this problem?
(or)
How to hide Current Source File Path in Download Dialog Box?
You can't. Your question isn't very clear, but I am assuming you mean the download dialog that Internet Explorer displays when downloading a file.
The control is defined by the browser creators and is hard coded. No browser that I am aware of gives any type of access to this control or any way to change it.

overwrite files (image) and delete image in c#?

I have a simple form which the users can use to upload images. It has a preview button so when User selects an image and clicks on preview, a postback occurs and I save the image to temporary folder and resize it and show it on the page. from there, the user can either submit form or edit the form. If he submits, everything is okay, I copy the resized image into correct folder.
If he clicks edit, and chooses another image, I need to delete the uploaded files (both original and resized) and If I do this:
File.Delete(HostingEnvironment.MapPath(TmpDirectory + PostImageName + ".jpg"));
File.Delete(HostingEnvironment.MapPath(TmpDirectory + PostImageName + "_small_.jpg"));
I get an exception saying some other process is using the image and It cant delete. (even after postback!)
and Also, if, instead of deleting that file, I try to save the new image with the same name so that it would overwrite, it still throws the error because file already exists.
There is no limit to the number of times the user can edit / preview so I cant save files incrementally (it doesn't even make sense to do this)
Also, after the postback, when the user goes back to edit mode and views the form the file upload control is empty. how can I get the file upload control to retain the value? all the other textboxes and text areas and checkboxes behave properly.
to summarize these are my questions:
1) how on earth (or rather, in c#) can I delete files without getting that exception?
OR
1) how to overwrite files?
2) how to make the file upload control retain its value between postbacks.
Thanks.
The exception talks for itself : Your file is still being used/opened by another process, i.e. thread, that you have launched. I bet it is the process by which you open the image file for reading. Make sure you have closed the relevant stream, ten bucks that it will solve your issue.
Why are you using a Bitmap to open the file on the server side? You should simply stream the "file" using
Response.TransmitFile(physicalFileNameAndPath).
Where TransmitFile expects (as a string) the physical file path and name.
The problem stems from the the way you send the file to the client. The file is still "locked" by the previous step. If you fix this, you'll be able to delete the file if needed.
I've not used the FileUpload control but it looks like you're using ViewState (which is what helps retain the values in the fields after postback. Either the FileUpload control does not support ViewState or you've not configured it to use ViewState.
you could assign the required property of the FileUpload control with the correct "value" so it shows what you've expect. This would mean that you'd have to capture the said value when the form is posted and simply re-assign the value back to the FileUpload control's property during the DataBind.
Make sure that your current
process doesn't have a write handle
open to the files in question
If there are no handles then try
turning off your virus scanner; an
overly aggressive virus scanner
could be taking a lock on those
files just after they have been created. This might be preventing you from deleting the files.

Can I upload a file without the FileUpload control's attached textbox?

In my ASP.NET project, I want to add a facility to my page so that when the user clicks a button, a 'browse file' dialog box directly opens up. After he selects the file in the dialog box, I want to save that image on the server, and update an imagebox based on that selection.
Is there some sort of dynamic 'browse for file' type dialog box that I can use?
You can check this demo.
Article (http://vremenno.net/js/javascript-snippets-plus-new-file-input/) is in Russian, but you can always use Google Translate.
Source code available here: (http://vremenno.net/examples/updated-file-input-styling/UpdatedFileInputStyling.zip)
Sorry for ugly links: this is my first post and I'm not allowed to use more than one link.

Looking for a standard way to manage documents in a WPF application

I'm writing a WPF application that uses one document at a time. Is there any standard way to implement the management of the current document? What I mean are the following functions:
New document: if there are not saved changes in the current document, a dialog box opens ('Do you want to save changes to {0}?') with Yes/No/Cancel buttons. If Cancel is hit, the operation stops.
Open document: same dialog box as at new document, and an Open dialog opens after
Save document: if the current document hasn't been saved, a Save dialog opens
Save as: you can imagine...
So, is there anything standard in the .NET framework like this or do I have to manually implement it?
You can check out Acropolis, I've never used it myself but I think it would help you http://windowsclient.net/Acropolis/Default.aspx

Categories

Resources