savefiledialog

how do you save from a savefile dialog in C#?

别来无恙 提交于 2019-12-04 19:35:21
here is the code I am currently using to open a file using the openfiledialog ` private void openToolStripMenuItem_Click_1(object sender, System.EventArgs e) { //opens the openfiledialog and gives the title. openFileDialog1.Title = "openfile"; //only opens files from the computer that are text or richtext. openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; //gets input from the openfiledialog. if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //loads the file and puts the content in the richtextbox. System.IO.StreamReader sr = new System.IO

SaveFileDialog AddExtension doesn't work as expected

早过忘川 提交于 2019-12-04 15:20:40
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 | Save as type | label1.Text | What I expect ----------------+----------------+----------------+----------

How to restrict FileDialog to specific path

家住魔仙堡 提交于 2019-12-04 12:59:49
Is it possible to restrict a file dialog(open/save) to a specific folder is winapi? OPENFILENAME fileDialogSettings; ... fileDialogSettings.lpstrInitialDir = "Some path"; ... if(GetOpenFileName(&fileDialogSettings)) { } I want to have "Some path" as root path in the dialog and to restrict navigation to this folder and it's sub folders only. May I use lpfnHook for this? Deanna If you're targeting Vista+ only, you can make use of the IFileDialogEvents::OnFolderChanging method to block the change altogether. For older versions of Windows, the OpenFileDialog allows you to specify a hook procedure

Issue while saving image using savefiledialog

我怕爱的太早我们不能终老 提交于 2019-12-04 04:58:09
问题 I'm using savefiledialog to save an image. Canvas is picturebox and the loaded image is bitmap. When I try to save it the file is created but somehow corrupted. Cause when I try againt load the image or show in different viewer it doesn't work - I mean the saved file is corrupted. There is an method for saving image. private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) { System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile(); try { switch (saveFileDialog1

Save File to MyDocuments + App Folder

爱⌒轻易说出口 提交于 2019-12-04 04:04:04
I am trying to save my .NET application settings file to the user's %MyDocument%\MyApplication folder, but I don't know how to check for an existing folder\file, and create or append the folder\file on save. I don't want to open a saveFileDialog because I need the file to be in the same place on all user computers. This is what I have so far, but it isn't working. Any help would be appreciated: var saveSettings = settingsList.text; //assign settings to a variable saveSettings = Regex.Replace(saveSettings, @"\s+", "").Trim() + Environment.NewLine; //remove any extra spaces and add a carriage

Forcing “Save As” dialog via jQuery GET

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 01:59:03
问题 I'm calling a jQuery "GET" on the test.php file code below. I'm trying to get the script to pop a "Save As" dialog on the resulting test.ini file to allow it to be saved locally. However, although I can echo the result back to the jQuery fine, I can't seem to pop the "save as" dialog. Update: Thanks to the solutions below, I just changed my $.get to a window.location.replace. $('#test').click( function() { //$.get('<?php echo get_bloginfo('template_directory') ?>/test.php'); window.location

How retrieve only filename from save file dialog [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-03 15:26:45
This question already has an answer here: Obtaining only the filename when using OpenFileDialog property “FileName” 2 answers I have a save file dialog and i want to get only the filename entered. Equivalent for openfiledialog.SafeFileName; Save file dialog has no SafeFileName Property and FileName returns both filename, path and extension. Pls how do i extract only file name. If you want the filename with extension use Path.GetFileName() . If you want it without the extension as well use Path.GetFileNameWithoutExtension() . public void Test(string fileName) { string path = Path

Save file with appropriate extension in a Save File prompt

隐身守侯 提交于 2019-12-03 09:52:24
In my application I use a SaveFileDialog to pop up a Save As window. I have restricted in the file type section the file to be saved as .dat with the following code. sfdialog.Filter = "Data Files (*.dat*)|*.dat*"; What I want to know how to do is make it automatically save with the .dat extension. Currently it just saves with no extension unless I specifically save it as filename.dat. Francis B. SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "Data Files (*.dat)|*.dat"; dlg.DefaultExt = "dat"; dlg.AddExtension = true; The AddExtension and DefaultExt properties. For example: sfdialog

Save text from rich text box with C#

两盒软妹~` 提交于 2019-12-02 14:15:17
This question has been answered. I've improved the code a bit (at least I think so). It now reminds of the aceepted answer to the question Open file in rich text box with C# . If I haven't made any mistakes (which I may have), the code should save a file with text from the rich text box rtfMain. The default file extension is .txt. You can also use the file extension .rtf. private void menuFileSave_Click(object sender, EventArgs e) { // Create a new SaveFileDialog object using (SaveFileDialog dlgSave = new SaveFileDialog()) try { // Default file extension dlgSave.DefaultExt = "txt"; //

suppress save/dialog in web browser and automate the download

ⅰ亾dé卋堺 提交于 2019-12-02 10:38:22
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 how to automate the download form the above link? The code i am using to get the link redirected is