savefiledialog

Save file dialog in MVC

假装没事ソ 提交于 2019-12-01 06:21:56
How to create save file dialog in MVC application? I couldn't find any example. Thanks in advance. By using the Content-Disposition header to attachment when returning the file to download: public ActionResult Download() { return File(@"c:\work\report.pdf", "application/pdf", "reoprt.pdf"); } Or if the file to download is dynamically generated: public ActionResult Download() { byte[] pdf = ... get the contents of the report return File(pdf, "application/pdf", "reoprt.pdf"); } 来源: https://stackoverflow.com/questions/6816727/save-file-dialog-in-mvc

C# SaveFileDialog in specific folder

限于喜欢 提交于 2019-12-01 03:15:58
I use SaveFileDialog to select the path where I want to save a file. I set InitialDirectory to some folder, but I want to limit the save locations to that folder or subfolders of that folder. Is this possible? SaveFileDialog dialog = new SaveFileDialog(); dialog.InitialDirectory = "SomePath"//this is the path that I want to be root folder No it is not possible. You can't directly set this as a Property on the SaveFileDialog . But you can try to do it by using the FileOk event to validate if the file is in that directory and otherwise cancel the event! dialog.FileOk += delegate (object sender,

C# SaveFileDialog in specific folder

試著忘記壹切 提交于 2019-11-30 23:23:40
问题 I use SaveFileDialog to select the path where I want to save a file. I set InitialDirectory to some folder, but I want to limit the save locations to that folder or subfolders of that folder. Is this possible? SaveFileDialog dialog = new SaveFileDialog(); dialog.InitialDirectory = "SomePath"//this is the path that I want to be root folder 回答1: No it is not possible. You can't directly set this as a Property on the SaveFileDialog . But you can try to do it by using the FileOk event to validate

How to use saveFileDialog for saving images in C#? [duplicate]

非 Y 不嫁゛ 提交于 2019-11-30 07:47:19
Possible Duplicate: Issue while saving image using savefiledialog I use windows forms in C#. How should I use saveFileDialog? I have picturebox and on the picture box there is an image and I want to save it. Loaded image is bmp. I want to save it as one of 4 formats: bmp, jpeg, png, tiff. I read some some notes on MDSN and also tryed it but I probably do something wrong. So I better ask how should be it write? How should be wrote method private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) and how should look like property saveFileDialog.Filter ? Thanks EDIT: What I've tryed:

Response.WriteFile() — not working asp net mvc 4.5

夙愿已清 提交于 2019-11-29 18:05:17
I've looked at many resources and the following should work, however my save as dialog box is never showing (not browser specific): Response.ContentType = "application/octet-stream"; string downloadName = "Request "+request.RequestID+ "_researchExport.doc"; Response.AddHeader("Content-Length", new System.IO.FileInfo(FileName).Length.ToString()); Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0};", downloadName)); Response.WriteFile(FileName); Response.Flush(); Response.End(); The file definitely exists. I've also tried the following: Using Response.TransmitFile

Word VBA - DocumentBeforeSave event?

人走茶凉 提交于 2019-11-29 12:58:35
I am using the following VBA code to make a message box appear while saving the Word document, Public WithEvents appWord as Word.Application Private Sub appWord_DocumentBeforeSave _ (ByVal Doc As Document, _ SaveAsUI As Boolean, _ Cancel As Boolean) Dim intResponse As Integer intResponse = MsgBox("Do you really want to " _ & "save the document?", _ vbYesNo) If intResponse = vbNo Then Cancel = True End Sub This code was written in a Class. But this does not work. Nothing happens when saving. What is the issue here? Codename K I made it to work. Thanks to AnalystCave.com for the help. This is

How to use saveFileDialog for saving images in C#? [duplicate]

怎甘沉沦 提交于 2019-11-29 10:29:38
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: Issue while saving image using savefiledialog I use windows forms in C#. How should I use saveFileDialog? I have picturebox and on the picture box there is an image and I want to save it. Loaded image is bmp. I want to save it as one of 4 formats: bmp, jpeg, png, tiff. I read some some notes on MDSN and also tryed it but I probably do something wrong. So I better ask how should be it write? How should be wrote

Default Filename SaveFileDialog

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 09:22:14
I would like to create SaveFileDialog with default file name from value DataGridViewCells So far I tried private void buttonSave_Click(object sender, EventArgs e) { //first //mySaveFileDialog.FileName = myDataGridView.SelectedCells[2].Value.ToString(); //second SaveFileDialog saveFile = new SaveFileDialog(); saveFile.FileName = myDataGridView.SelectedCells[2].Value.ToString(); saveFile.ShowDialog(); } Can anyone help me solve this? M.Babcock The SaveFileDialog has a property intended for this purpose: DefaultFileName using Silverlight or FileName using .NET Your (uncompilable) code from the

VBA: Get Excel FileDialogOpen to point to “My Computer” by default

纵然是瞬间 提交于 2019-11-29 08:04:15
I'm trying to get excels save and open dialog boxes to open to "my computer" by default so the user can select a drive from there. I have got the dialog boxes to open to any path on any drive or my documents etc but can't seem to find a way for it to open to my computer. This is the code i'm using at the moment and it works fine for a known path: MsgBox objFolders("desktop") ChDrive objFolders("desktop") ChDir objFolders("desktop") strFileName = appRemoteApp.Workbooks("Export Template.xlsm").Application.GetSaveAsFilename(objFolders("desktop") & "\Replica Export " & UserName & " " & Format(Date

A Generic error occurs at GDI+ at Bitmap.Save() after using SaveFileDialog

泪湿孤枕 提交于 2019-11-28 09:39:15
I use the following code block with some more code inside the using block: using (System.Drawing.Bitmap tempImg = (System.Drawing.Bitmap)tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap)) { // ... tempImg.Save("..\\..\\testdata\\tempImg.bmp", ImageFormat.Bmp); // ... } But I still get the error: A Generic Error occured at GDI+ only after I make some action which is not related to the code inside the using block. In other times this works well. Also the tempImg.bmp is a temporary file, so I delete the tempImg.bmp within the using block itself. Since the tempImg is inside the using and