savefiledialog

SaveFileDialog should I use the FilterIndex property or the extension of the FileName property?

断了今生、忘了曾经 提交于 2021-02-08 10:09:06
问题 The other day I had the following question SaveFileDialog AddExtension doesn't work as expected. Now a follow up question came to my mind. Should I use the FilterIndex property or the extension of the FileName property of the SaveFileDialog to decide under which file format I want to store the data? I've the following C# test code: var dialog = new SaveFileDialog(); dialog.AddExtension = true; dialog.DefaultExt = "txt"; dialog.Filter = "Text files (*.txt)|*.txt|XML files (*.xml)|*.xml";

OpenFileDialog causes WPF app to crash

狂风中的少年 提交于 2021-01-28 06:19:52
问题 In my WPF Application I used OpenFileDialog to select an image and load it to app, this works fine as expected. But if I run same app from a flash drive, image loades after that UI freezes, any clicks on UI makes app to crash. I have admin manifest to app also. 回答1: I couldn't find a good explanation but I solved this problem setting the InitialDirectory with a valid local path (e.g., Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) 回答2: I've seen something similar to this

How to use Win32API SendMessage to change Save Dialog File Location?

蓝咒 提交于 2020-08-25 07:25:27
问题 I am writing a program that automates saving data to a specific location, based on the common Save/Save As dialog. There are two attacking approaches. Both approaches require monitoring handles for messages under Spyxx (so essentially we are trying to replicate the SendMessage) The first approach to set the File Name with target path, using Win32 SendMessage API. The HWnd in this case is the Edit field next to the File name. [DllImport("user32.dll")] public static extern IntPtr SendMessage

Really Custom OpenFileDialog .NET

心不动则不痛 提交于 2020-05-10 06:48:08
问题 I want to have an custom OpenFileDialog form within my project where I can add/remove buttons and customize whatever I want like a normal form. This is mainly so that it fits into the theme I am using, additionally, I can add custom buttons. Is there any tutorials on how I could construct my own? Are there any pre-existing projects I can use straight out of the download? 回答1: I hope that will fit your requirements: You will need one TreeView and an ImageList Code You will need System.Runtime

SaveFileDialog AddExtension doesn't work as expected

谁说胖子不能爱 提交于 2020-01-23 02:57:18
问题 I've the following C# code, which is using the SaveFileDialog and set's the AddExtension property to true : var dialog = new SaveFileDialog(); dialog.AddExtension = true; dialog.DefaultExt = "txt"; dialog.Filter = "Text files (*.txt)|*.txt|XML files (*.xml)|*.xml"; dialog.OverwritePrompt = true; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { label1.Text = dialog.FileName; } And I've tested the following combination of File name and Save as type of the dialog. File name |

suppress save/dialog in web browser and automate the download

旧时模样 提交于 2020-01-11 13:24:35
问题 I want to automate the download of an exe prompted from a link from the client side. I can get the first redirected link from http://go.microsoft.com/fwlink/?LinkID=149156 to http://www.microsoft.com/getsilverlight/handlers/getsilverlight.ashx. Please click and check how it works. fwlink -> .ashx - >.exe ...i want to get the direct link to the .exe. But the response returns 404 when requesting the Web handler through the code but if you try on Browser it actually downloads. Can anyone suggest

saving data from a query as a csv file

删除回忆录丶 提交于 2020-01-04 02:49:09
问题 I've got an application which opens a csv file and displays all the contents into a formatted datagridview. From there I have a button which opens another form that contains a series of checkboxes. The check boxes have all the attributes of the csv file we opened before, and the user is supposed to be able to query the file based on witch attributes they want, then save the file. For example, if they only want a file which displays all the entries for animals with wings, they select the wings

How to do something if cancel button on save file dialog was clicked?

雨燕双飞 提交于 2020-01-03 08:53:12
问题 I am using c# WinForms. I have a save dialog box that pops up and a message box after that that says it was saved successfully. I just realized that if a user clicks cancel, my message box still comes. How do i tell when a user clicks the cancel button on a save dialog box and then do something when it is cancelled? 回答1: A save dialog box after closing has the DialogResult property set to what happens. In your case: if (mySaveDialog.DialogResult == DialogResult.OK) { /* show saved ok */ } 回答2

Save File Dialog , restrict name

﹥>﹥吖頭↗ 提交于 2020-01-02 07:28:29
问题 my program has a save file option which is shown below : //Browse for file SaveFileDialog ofd = new SaveFileDialog(); ofd.Filter = "CSV|*.csv"; ofd.DefaultExt = ".csv"; DialogResult result = ofd.ShowDialog(); string converted = result.ToString(); if (converted == "OK") { Master_Inventory_Export_savePath.Text = ofd.FileName; } if I write the file name as "example" it saves correctly as a .csv however if I set the name as "example.txt" it saves as a text file , I've looked on msdn etc but even

How do I save an Excel file without getting a format warning when opening, using C# and Excel 2010

可紊 提交于 2020-01-02 06:17:33
问题 I'm using Excel 2010. I'm trying so save my excel file, with this code. It does save a .xls file, but when I open the file I get this message: The file you are trying to open, 'tre.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a thrusted source before opening the file. Do you want to open the file now? If I press yes the file opens. But what do I need to get rid of this format-popup? My code: using System; using System