private bool DoSave() { if (string.IsNullOrEmpty(mFilePath)) { var res = SaveFileDlg.ShowDialog(); if (res != DialogResult.OK) { return(false); } mFilePath = SaveFileDlg.FileName; } var rtCfg = new RuntimeConfig { PanelIcon = BrowseIcon.FileName, PanelText = PanelText.Text, RibbonText = RibbonText.Text, TabText = TabText.Text, CommandConfigs = mConfigs }; rtCfg.SaveToFile(mFilePath); mDirty = false; UpdateUserInterface(); return(true); }
/// <summary> /// 保存文件 /// </summary> /// <returns></returns> public static string SaveFile() { SaveFileDlg pth = new SaveFileDlg(); pth.structSize = System.Runtime.InteropServices.Marshal.SizeOf(pth); pth.filter = "txt (*.txt)"; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.initialDir = Application.dataPath; // default path pth.title = "保存项目"; pth.defExt = "txt"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; if (SaveFileDialog.GetSaveFileName(pth)) { string filepath = pth.file;//选择的文件路径; Debug.Log(filepath); return(filepath); } else { return(""); } }
public void SaveProject() { SaveFileDlg pth = new SaveFileDlg(); pth.structSize = Marshal.SizeOf(pth); pth.filter = "All files (*.*)|*.*"; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.initialDir = Application.dataPath; pth.title = "Save Project"; pth.defExt = "dat"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; if (SaveFileDialog.GetSaveFileName(pth)) { string filepath = pth.file; Debug.Log(filepath); StreamWriter sw = new StreamWriter(filepath); string result = sb.ToString().Substring(0, sb.ToString().Length - 1); string[] s = result.Split(','); for (int i = 0; i < s.Count() / 3; i++) { sw.WriteLine(s[i * 3] + "," + s[i * 3 + 1] + "," + s[i * 3 + 2]); } sw.Flush(); sw.Close(); } }
protected void DownAtt(string tableName) { #region 载附件 try { BusinessObject bo = new BusinessObject(); string sql = "select AttName,AttExt,Attachment from " + tableName + " where " + m_strPKM + " = " + m_dvM[0][m_strPKM]; bo.BusiDataSQL = new string[] { sql }; bo.GetBusiData(); if (bo.BusiData.Tables[0].Rows[0]["Attachment"].ToString() != "") { SaveFileDlg.FileName = this.m_dvM[0]["AttName"].ToString(); SaveFileDlg.DefaultExt = this.m_dvM[0]["AttExt"].ToString(); if (SaveFileDlg.ShowDialog() == DialogResult.OK) { byte[] buffByte = (byte[])bo.BusiData.Tables[0].Rows[0]["Attachment"]; FileInfo fi = new FileInfo(SaveFileDlg.FileName); FileStream fs = fi.OpenWrite(); fs.Write(buffByte, 0, buffByte.Length); fs.Close(); fi.CopyTo(SaveFileDlg.FileName); fi.Delete(); } } else { MsgBox.ShowInfoMsg("没有附件!"); } } catch { } #endregion }
/// <summary> /// 保存文件项目 /// </summary> public static string SaveProject() { SaveFileDlg pth = new SaveFileDlg(); pth.structSize = Marshal.SizeOf(pth); pth.filter = "All files (*.*)|*.*"; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.initialDir = Application.dataPath.Replace("/", "\\"); //默认路径 pth.title = "保存项目"; pth.defExt = "asset"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; if (SaveFileDialog.GetSaveFileName(pth)) { //选择的文件路径; string filepath = pth.file; //Debug.Log(filepath); return(filepath); } else { return(null); } }
private void BtnSave_Click(object sender, EventArgs e) { if (SaveFileDlg.ShowDialog() == DialogResult.OK) { string fileName = SaveFileDlg.FileName; File.WriteAllText(fileName, TxtBox.Text); } }
private void BtnCreateDB_Click(object sender, EventArgs e) { SaveFileDlg.Filter = "FichierAccess|*.mdb|Tous fichiers|*.*"; SaveFileDlg.ShowDialog(); string Creationpath = SaveFileDlg.FileName; CreateDB(Creationpath); MessageBox.Show("The database has been created !", "Successful creation", MessageBoxButtons.OK, MessageBoxIcon.Information); getPath = Creationpath; OpenDB f1 = new OpenDB(); f1.ShowDialog(); }
void OnTagInstanceExtractAs(BlamLib.Blam.CacheIndex.Item tag_instance) { SaveFileDlg.Filter = tag_instance.GroupTag.Filter; if (SaveFileDlg.ShowDialog(this) == DialogResult.OK) { string path = SaveFileDlg.FileName; var tiei = new TagInstanceExtractionInfo(); tiei.InitializeStateForTagInstance(tag_instance, System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), @"\"), System.IO.Path.GetFileNameWithoutExtension(path)); tiei.InitializeExtractionForTagInstance(); bgwTagExtract.RunWorkerAsync(tiei); } SaveFileDlg.Filter = ""; }
public void Btn_Stop_Click() { hawkNum.enabled = true; doveNum.enabled = true; foodNum.enabled = true; foodValue.enabled = true; injury.enabled = true; bluffing.enabled = true; baseReq.enabled = true; btn_Next.enabled = false; btn_Stop.enabled = false; btn_Start.enabled = true; SaveFileDlg pth = new SaveFileDlg(); pth.structSize = Marshal.SizeOf(pth); pth.filter = "All files (*.*)|*.*"; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.initialDir = Application.dataPath; pth.title = "Save Project"; pth.defExt = "dat"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; if (SaveFileDialog.GetSaveFileName(pth)) { string filepath = pth.file; Debug.Log(filepath); StreamWriter sw = new StreamWriter(filepath); string result = sb.ToString().Substring(0, sb.ToString().Length - 1); string[] s = result.Split(','); for (int i = 0; i < s.Count() / 3; i++) { sw.WriteLine(s[i * 3] + "," + s[i * 3 + 1] + "," + s[i * 3 + 2]); } sw.Flush(); sw.Close(); } }
/// <summary> /// 保存文件项目 /// </summary> public void SaveProject(FileType fileType) { SaveFileDlg pth = new SaveFileDlg(); pth.structSize = Marshal.SizeOf(pth); switch (fileType) { case FileType.All: pth.filter = "All files (*.*)\0*.*"; break; case FileType.png: pth.filter = "All files (*.png)\0*.png"; break; case FileType.jpg: pth.filter = "All files (*.jpg)\0*.jpg"; break; case FileType.txt: pth.filter = "All files (*.txt)\0*.txt"; break; case FileType.json: pth.filter = "All files (*.json)\0*.json"; break; default: break; } pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.initialDir = Application.dataPath; //默认路径 pth.title = "保存项目"; pth.defExt = "dat"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; if (SaveFileDialog.GetSaveFileName(pth)) { string filepath = pth.file; //选择的文件路径; Debug.Log(filepath); } }
public static string GetSaveFilePath() { SaveFileDlg pth = new SaveFileDlg(); pth.structSize = System.Runtime.InteropServices.Marshal.SizeOf(pth); pth.filter = "REC (*.rec)\0*.rec\0\0"; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.title = "选择存档保存的位置"; pth.defExt = "rec"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008 | 0x00000002; if (SaveFileDialog.GetSaveFileName(pth)) { string filepath = pth.file; return(filepath); } return(null); }
/// <summary> /// 保存文件项目 /// </summary> public void SaveProject() { SaveFileDlg pth = new SaveFileDlg(); pth.structSize = Marshal.SizeOf(pth); pth.filter = "All files (*.*)|*.*"; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.initialDir = Application.dataPath; //默认路径 pth.title = "保存项目"; pth.defExt = "dat"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; if (SaveFileDialog.GetSaveFileName(pth)) { string filepath = pth.file; //选择的文件路径; UnityEngine.Debug.Log(filepath); } }
/// <summary> /// 保存文件对话框 /// </summary> /// <param name="saveFilter">保存文件的后缀名,一定要是.png,.mp4之类</param> /// <param name="defaultPath">默认打开的路径</param> /// <returns></returns> public static string SaveFileDialog(string saveFilter, string defaultPath) { var pth = new SaveFileDlg(); pth.structSize = Marshal.SizeOf(pth); pth.filter = saveFilter; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.initialDir = defaultPath; // default path pth.title = "保存为"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; if (GetSaveFileName(pth)) { return(pth.file + pth.filter); } return(""); }
/// <summary> /// 保存项目 /// </summary> public string SaveProject(Action <string> _event) { SaveFileDlg _openFileDlg = new SaveFileDlg(); _openFileDlg.structSize = Marshal.SizeOf(_openFileDlg); _openFileDlg.filter = filter; _openFileDlg.file = defaultFileName + new string(new char[256 - defaultFileName.Length]); _openFileDlg.maxFile = _openFileDlg.file.Length; _openFileDlg.fileTitle = new string(new char[64]); _openFileDlg.maxFileTitle = _openFileDlg.fileTitle.Length; _openFileDlg.initialDir = defaultPath; //默认路径 _openFileDlg.title = windowTitle; _openFileDlg.defExt = defaultExt; _openFileDlg.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; if (SaveFileDialog.GetSaveFileName(_openFileDlg)) { string _filepath = _openFileDlg.file;//选择的文件路径; _event(_filepath); return(_filepath); } return(null); }
private void SaveDocument(bool newLocation) { UpdateDocument(); if (Program.Document != null) { newLocation |= String.IsNullOrEmpty(Program.Document.FilePath); } if (newLocation) { if (SaveFileDlg.ShowDialog(this) == DialogResult.OK) { Program.Document.SaveAs(SaveFileDlg.FileName); } } else { Program.Document.Save(); } Text = "Midi Mapper - [" + Program.Document.FilePath + "]"; }
public static extern bool GetSaveFileName([In, Out] SaveFileDlg ofd);
private static extern bool GetSaveFileName([In, Out] SaveFileDlg ofd);
//保存 private void MenuItemSave_Click(object sender, EventArgs e) { if (_openmp3 == "") { MessageBox.Show(this, "未打开mp3文件,请重新打开!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); MenuItemOpen_Click(sender, e); return; } if (_maker == "" || _fileName == "") { MessageBox.Show(this, "无文件信息,请修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); MenuItemFileInfo_Click(sender, e); return; } if (_openSong == "") { if (SaveFileDlg.ShowDialog() == DialogResult.OK) { _openSong = SaveFileDlg.FileName; } else { return; } } string savePath = Path.GetTempPath() + "RTMP\\"; if (Directory.Exists(Path.GetTempPath() + "RTMP")) { Directory.Delete(Path.GetTempPath() + "RTMP", true); } Directory.CreateDirectory(savePath); File.Copy(_openmp3, savePath + "song.mp3"); FileStream fileStream = new FileStream(savePath + "song.map", FileMode.Create); BinaryWriter binaryWriter = new BinaryWriter(fileStream); //文件信息 binaryWriter.Write(_fileName); //曲名 binaryWriter.Write(_maker); //制作者 //binaryWriter.Write(1);//模式,已删除 binaryWriter.Write(_difficulty); //难度 binaryWriter.Write(_description); //描述 binaryWriter.Write(listBoxSave.Items.Count); //数目 //音符信息 for (int i = 0; i < listBoxSave.Items.Count; i++) { mykey = (MyKey)listBoxSave.Items[i]; binaryWriter.Write(mykey.myKeyShow); binaryWriter.Write(mykey.timeMin); binaryWriter.Write(mykey.timeSec); binaryWriter.Write(mykey.timeMs); binaryWriter.Write(mykey.keyCount); binaryWriter.Write(mykey.A); binaryWriter.Write(mykey.S); binaryWriter.Write(mykey.D); binaryWriter.Write(mykey.F); binaryWriter.Write(mykey.Space); binaryWriter.Write(mykey.J); binaryWriter.Write(mykey.K); binaryWriter.Write(mykey.L); binaryWriter.Write(mykey.Sem); } binaryWriter.Close(); fileStream.Close(); CreateZipFile(savePath, savePath + _fileName + ".rtm"); System.IO.File.Copy(savePath + _fileName + ".rtm", _openSong, true); }
private void Save() { SaveFileDlg pth = new SaveFileDlg(); pth.structSize = Marshal.SizeOf(pth); pth.filter = "bytes (*.bytes)"; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; pth.initialDir = Application.dataPath + "/HotUpdateRes/Story"; // default path UDebug.Log(Application.dataPath + "/HotUpdateRes/Story"); pth.title = "保存story数据"; pth.defExt = "bytes"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; Dictionary <string, int> plottext = new Dictionary <string, int>(); string path = Application.dataPath + "/HotUpdateRes/Config/PlotTextConfig.txt"; if (!File.Exists(path)) { UDebug.LogError("can not find file : " + path); return; } string[] text = File.ReadAllLines(path); bool isChangeConfig = false; for (int i = 2; i < text.Length; i++) { if (string.IsNullOrEmpty(text[i])) { continue; } string[] plot = text[i].Split('\t'); try { plottext.Add(plot[1], int.Parse(plot[0])); } catch (Exception e) { UDebug.Log(e.Message); UDebug.LogError("第一段:" + plot[0]); UDebug.LogError("第二段:" + plot[1]); throw; } } for (int i = 0; i < nodeRootList.Count; i++) { if (string.IsNullOrEmpty(((StoryNode)nodeRootList[i]).text)) { ((StoryNode)nodeRootList[i]).textId = 0; } else if (plottext.ContainsKey(((StoryNode)nodeRootList[i]).text)) { ((StoryNode)nodeRootList[i]).textId = plottext[((StoryNode)nodeRootList[i]).text]; } else { int pltid = plottext[plottext.Keys.Last <string>()] + 1; plottext.Add(((StoryNode)nodeRootList[i]).text, pltid); ((StoryNode)nodeRootList[i]).textId = pltid; isChangeConfig = true; } } if (isChangeConfig) { string[] newtext = new string[plottext.Count + 2]; int i = 2; newtext[0] = "id" + "\t" + "text"; newtext[1] = "int" + "\t" + "string"; foreach (var item in plottext) { newtext[i] = item.Value + "\t" + item.Key; i++; } File.WriteAllLines(Application.dataPath + "/HotUpdateRes/Config/PlotTextConfig.txt", newtext); } if (SaveFileDialog.GetSaveFileName(pth)) { string filepath = pth.file; //选择的文件路径; if (!OnSaveCheck()) { return; } bool isSuccess = BinaryUtil.ObjectToFile(filepath, nodeRootList[0]); if (isSuccess) { path = filepath; UDebug.Log("Save succeed!"); } else { UDebug.LogError("Save failed!"); } } }