当前位置: 首页>>代码示例>>C#>>正文


C# SaveFileDialog.Dispose方法代码示例

本文整理汇总了C#中SaveFileDialog.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SaveFileDialog.Dispose方法的具体用法?C# SaveFileDialog.Dispose怎么用?C# SaveFileDialog.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SaveFileDialog的用法示例。


在下文中一共展示了SaveFileDialog.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BackupData

        /// <summary>
        /// Backup current user's settings and problem description into a .uapak file.
        /// Depends on external program "unzip\unzip.exe"
        /// </summary>
        public static void BackupData()
        {
            string path = LocalDirectory.DefaultPath;
            if (!System.IO.Directory.Exists(path)) return;

            string file = @"unzip\unzip.exe";
            file = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), file);
            if (!System.IO.File.Exists(file)) return;

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.FileName = "Problems.uapak";
            sfd.Filter = "UVA Arena Package | *.uapak";
            sfd.DefaultExt = ".uapak";
            sfd.AddExtension = true;
            sfd.CheckPathExists = true;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(Backup, sfd.FileName);
            }
            sfd.Dispose();
        }
开发者ID:nocmnt,项目名称:UVA-Arena,代码行数:26,代码来源:Functions.cs

示例2: btnInject_Click

	private void btnInject_Click(object sender, EventArgs e)
	{
		//inject dll
		if (File.Exists(proExe.Text) == false)
		{
			MessageBox.Show("Dbpro Exe not found.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
			return;
		}
		if (dllList.SelectedIndex == -1)
		{
			MessageBox.Show("No dll selected.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
			return;
		}
		string selectedDll = Application.StartupPath + Path.DirectorySeparatorChar + "dll" + Path.DirectorySeparatorChar
			+ dllList.Items[dllList.SelectedIndex] + Path.DirectorySeparatorChar + "compress.dll";
		if (File.Exists(selectedDll) == false)
		{
			MessageBox.Show("Selected dll dir does not contain \"compress.dll\".", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
			return;
		}
		SaveFileDialog sfd = new SaveFileDialog();
		sfd.Title = "Save injected exe as";
		sfd.Filter = "Exe Files (*.exe)|*.exe|All Files (*.*)|*.*";
		if (sfd.ShowDialog() == DialogResult.OK)
		{
			Cursor.Current = Cursors.WaitCursor;
			DB.proExe.InjectDll(proExe.Text, sfd.FileName, selectedDll);
			Cursor.Current = Cursors.Default;
		}
		sfd.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:31,代码来源:main.cs

示例3: mSaveOnClick

	private void mSaveOnClick(object sender, EventArgs e)
	{
		//save exe
		if (contents.Items.Count > 0)
		{
			SaveFileDialog sfd = new SaveFileDialog();
			sfd.Filter = "Exe or Pck files (*.exe, *.pck)|*.exe;*.pck|All Files (*.*)|*.*";
			sfd.Title = "Save exe";
			if (sfd.ShowDialog() == DialogResult.OK)
			{
				Cursor.Current = Cursors.WaitCursor;
				bool dbPro = false;
				if (exeType.SelectedIndex == exeType.Items.IndexOf("DbPro"))
					dbPro = true;
				proExe.SaveExe(contents.Items, sfd.FileName, exeName.Text, dbPro, displaySettings);
				if (exeName.Text == "")
					exeName.Text = sfd.FileName;
				Cursor.Current = Cursors.Default;
			}
			sfd.Dispose();
		}
		else
		{
			//nothing to save
			MessageBox.Show("Nothing to save!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:27,代码来源:main.cs

示例4: mExternaliseOnClick

	private void mExternaliseOnClick(object sender, EventArgs e)
	{
		//Externalise dlls
		//Moves dlls from within the exe to the exe directory
		//Similar to the ExternaliseDLLS=Yes dbpro compiler option discussed here
		//http://forum.thegamecreators.com/?m=forum_view&t=129081&b=18
		
		//can't externalise compressed exes
		if (proExe.IsCompressed(contents) == true)
		{
			MessageBox.Show("Exe is already compressed.", "Error!",
				MessageBoxButtons.OK, MessageBoxIcon.Error);
			return;
		}

		//don't externalise .pck files or dbc exes
		if (contents.Items.Count < 2 || contents.Items[1].Text != ListViewStrings.VirtualDat)
		{
			MessageBox.Show("Exe is a .pck or dbc exe", "Error!",
				MessageBoxButtons.OK, MessageBoxIcon.Error);
			return;
		}

		SaveFileDialog sfd = new SaveFileDialog();
		sfd.Title = "Save externalised Exe as";
		sfd.Filter = "Exe Files (*.exe)|*.exe|All Files (*.*)|*.*";
		if (sfd.ShowDialog() == DialogResult.OK)
		{
			String directory = Path.GetDirectoryName(sfd.FileName);
			ArrayList files = new ArrayList();
			foreach (ListViewFileItem lvi in contents.Items)
			{
				if (lvi.Text.EndsWith(".dll"))
				{
					//save dll in directory
					proExe.ExtractFile(lvi, exeName.Text, directory + Path.DirectorySeparatorChar + lvi.Text);
				}
				else
				{
					//not a dll, add it to list of files to save in exe
					files.Add(lvi);
				}
			}
			proExe.SaveExe(files, sfd.FileName, exeName.Text, true, displaySettings);
		}

		sfd.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:48,代码来源:main.cs

示例5: mCompressOnClick

	private void mCompressOnClick(object sender, EventArgs e)
	{
		//compress exe
		//decompress loaded exe
		SaveFileDialog sfd = new SaveFileDialog();
		sfd.Title = "Save compressed exe/pck as";
		sfd.Filter = "Exe or Pck Files (*.exe, *.pck)|*.exe;*.pck|All Files (*.*)|*.*";
		OpenFileDialog ofd = new OpenFileDialog();
		ofd.Title = "Select " + ListViewStrings.CompressDll;
		ofd.Filter = ListViewStrings.CompressDll + "|" + ListViewStrings.CompressDll + "|Dll Files (*.dll)|*.dll|All Files (*.*)|*.*";
		//check for compress.dll to ensure exe is not compressed.
		if (proExe.IsCompressed(contents) == true)
		{
			MessageBox.Show("Exe is already compressed.", "Error!",
				MessageBoxButtons.OK, MessageBoxIcon.Error);
			return;
		}
		if (sfd.ShowDialog() == DialogResult.OK)
		{
			//Make sure filenames don't match, this is really just to ensure there is a backup incase compression fails
			if (exeName.Text == sfd.FileName)
			{
				MessageBox.Show("Compressed exe filename and decompressed exe filename must be different.", "Error!",
					MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}
			if (ofd.ShowDialog() == DialogResult.OK)
			{
				Cursor.Current = Cursors.WaitCursor;
				bool dbPro = false;
				if (exeType.SelectedIndex == exeType.Items.IndexOf("DbPro"))
					dbPro = true;
				proExe.CompressExe(contents.Items, dbPro, displaySettings, exeName.Text, sfd.FileName, ofd.FileName);
				Cursor.Current = Cursors.Default;
			}
		}
		sfd.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:38,代码来源:main.cs

示例6: mExtractOnClick

	private void mExtractOnClick(object sender, EventArgs ea)
	{
		//extract file
		foreach (ListViewFileItem lvi in contents.SelectedItems)
		{
			SaveFileDialog sfd = new SaveFileDialog();
			sfd.Title = "Extract file as";
			sfd.Filter = "All Files (*.*)|*.*";
			//extract file
               sfd.FileName = Path.GetFileName(proExe.DbcRemoveNull(lvi.Text));
			if (sfd.ShowDialog() == DialogResult.OK)
			{
				Cursor.Current = Cursors.WaitCursor;
				proExe.ExtractFile(lvi, exeName.Text, sfd.FileName);
				Cursor.Current = Cursors.Default;
			}
			sfd.Dispose();
		}
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:19,代码来源:main.cs

示例7: SaveObjectList

        private void SaveObjectList()
        {
            if (Cameras.Count == 0 && Microphones.Count == 0)
            {
                MessageBox.Show(LocRm.GetString("NothingToExport"), LocRm.GetString("Error"));
                return;
            }

            var saveFileDialog = new SaveFileDialog
                                 {
                                     InitialDirectory = _lastPath,
                                     Filter = "iSpy Files (*.ispy)|*.ispy|XML Files (*.xml)|*.xml"
                                 };

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string fileName = saveFileDialog.FileName;

                if (fileName.Trim() != "")
                {
                    SaveObjects(fileName);
                    try
                    {
                        var fi = new FileInfo(fileName);
                        _lastPath = fi.DirectoryName;
                    }
                    catch
                    {
                    }
                }
            }
            saveFileDialog.Dispose();
        }
开发者ID:flos-club,项目名称:iSpy,代码行数:33,代码来源:MainForm.cs

示例8: save_Click

	private void save_Click(object sender, EventArgs e)
	{
		//save
		SaveFileDialog dlg = new SaveFileDialog();
		dlg.Title = "Save";
		dlg.Filter = "Builder settings file (*.bsf)|*.bsf|All Files (*.*)|*.*";
		if (dlg.ShowDialog() == DialogResult.OK)
		{
			try
			{
				FileStream fs = new FileStream(dlg.FileName,FileMode.Create);
				BinaryWriter bw = new BinaryWriter(fs);
				bw.Write(name.Text);
				bw.Write(filename.Text);
				bw.Write(checksum.Text);
				bw.Write(info.Text);
			
				//files
				foreach (ListViewFileItem items in files.Items)
				{
					bw.Write(items.Text);
					bw.Write(items.SubItems[1].Text);
					bw.Write(items.SubItems[2].Text);
					bw.Write(items.Offset);
					bw.Write(items.Size);
				}

				bw.Close();
				fs.Close();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
		dlg.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:37,代码来源:main.cs

示例9: build_Click


//.........这里部分代码省略.........
		if (name.Text == "")
		{
			MessageBox.Show("No window title","Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			return;
		}
		if (filename.Text == "")
		{
			MessageBox.Show("No filename","Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			return;
		}
		if (info.Text == "")
		{
			MessageBox.Show("No info text","Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			return;
		}
		//check checksum is valid
		if (checksum.Text.Length != 32 && checksum.Text.Length != 0)
		{
			MessageBox.Show("Invalid Checksum value","Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			return;
		}
		if (files.Items.Count == 0)
		{
			MessageBox.Show("No files","Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			return;
		}
		SaveFileDialog dlg = new SaveFileDialog();
		dlg.Title = "Save Patch";
		dlg.Filter = "Exe Files (*.exe)|*.exe|All Files (*.*)|*.*";
		if (dlg.ShowDialog() == DialogResult.OK)
		{
			try
			{
				//copy install.exe to new file
				File.Copy(Application.StartupPath+"\\patcher.dat",dlg.FileName, true);
				FileStream fs = new FileStream(dlg.FileName,FileMode.Append);
				BinaryWriter bw = new BinaryWriter(fs);

				//name
				write_text(bw,name.Text);
				//filename
				write_text(bw,filename.Text);
				//checksum
				if (checksum.Text == "")
				{
					bw.Write((byte) 0);
				}
				else
				{
					bw.Write((byte) 1);
					bw.Write(Encoding.ASCII.GetBytes(checksum.Text));
				}
				//info
				write_text(bw,info.Text);
				
				//files
				bw.Write((byte)files.Items.Count);
				for (int i=0; i<files.Items.Count; i++)
				{
					//action "Add/Replace" "Remove"
					if (files.Items[i].SubItems[1].Text == "Add/Replace")
						bw.Write((byte)0);
					if (files.Items[i].SubItems[1].Text == "Remove")
						bw.Write((byte)1);
					//filename
					write_text(bw,files.Items[i].Text);
					//filedata if required
					if (files.Items[i].SubItems[1].Text == "Add/Replace")
					{
						ListViewFileItem lvi = (ListViewFileItem) files.Items[i];
						FileStream fsin = new FileStream(files.Items[i].SubItems[2].Text,FileMode.Open);
						BinaryReader brin = new BinaryReader(fsin);
						if (lvi.Size == -1)
						{
							//normal file
							bw.Write((int)fsin.Length);
							bw.Write(brin.ReadBytes((int)fsin.Length));
						}
						else
						{
							//file with offset and size
							fsin.Seek(lvi.Offset, SeekOrigin.Begin);
							bw.Write(lvi.Size);
							bw.Write(brin.ReadBytes(lvi.Size));
						}
						brin.Close();
						fsin.Close();
					}
				}

				bw.Close();
				fs.Close();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
		dlg.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:101,代码来源:main.cs

示例10: menuItemSave_Click

 // save drawing in bitmap DrawArea as a jpeg file
 private void menuItemSave_Click(object sender, System.EventArgs e)
 {
     ImageFormat format = ImageFormat.Gif;
     SaveFileDialog sfd = new SaveFileDialog();
     if(currentSymbol!=null)
         sfd.FileName=currentSymbol.name;
     sfd.Filter = "GIF Files(*.GIF)|*.GIF|Windows Metafile (*.EMF)|*.EMF";
     if (sfd.ShowDialog()  == DialogResult.OK) {
         if(sfd.FileName.EndsWith(".EMF")) {
             saveEmf(sfd.FileName);
         } else {
             DrawArea.Save(sfd.FileName, format );
         }
         EbnfForm.WriteLine("Rule " + currentSymbol.name + " saved to "+sfd.FileName+".");
     }
     sfd.Dispose();
 }
开发者ID:fperezpt,项目名称:EBNFVisualizer,代码行数:18,代码来源:EbnfForm.cs

示例11: mDecompressOnClick

	private void mDecompressOnClick(object sender, EventArgs e)
	{
		//decompress loaded exe
		SaveFileDialog sfd = new SaveFileDialog();
		sfd.Title = "Save decompressed exe as";
		sfd.Filter = "Exe Files (*.exe)|*.exe|All Files (*.*)|*.*";
		//check for compress.dll to ensure exe is compressed.
		if (contents.Items.Count < 3 || contents.Items[1].Text.ToLower() != "compress.dll")
		{
			MessageBox.Show("Exe is not compressed.", "Error!",
				MessageBoxButtons.OK, MessageBoxIcon.Error);
			return;
		}
		if (sfd.ShowDialog() == DialogResult.OK)
		{
			//Make sure filenames don't match, this is really just to ensure there is a backup incase decompression fails
			if (exeName.Text == sfd.FileName)
			{
				MessageBox.Show("Compressed exe filename and decompressed exe filename must be different.", "Error!",
								MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}
			Cursor.Current = Cursors.WaitCursor;
			bool dbPro = false;
			if (exeType.SelectedIndex == exeType.Items.IndexOf("DbPro"))
				dbPro = true;
			proExe.DecompressExe(contents, dbPro, this, exeName.Text, sfd.FileName);
			Cursor.Current = Cursors.Default;
		}
		sfd.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:31,代码来源:main.cs

示例12: btnSave_Click


//.........这里部分代码省略.........
									brOut.Write(brUpx.ReadBytes(length));
									brUpx.Close();
									fsUpx.Close();
									//delete "___upx.dll"
									File.Delete("___upx.dll");
								}
							}
							else
							{
								//write file length
								brOut.Write(length);
								//check for "_virtual.dat" and use display settings
								if (items.Text == "_virtual.dat")
								{
									//seek over display info
									fsIn.Seek(16,SeekOrigin.Current);
									//write display info
									brOut.Write(displayType.SelectedIndex);
									brOut.Write(int.Parse(displayWidth.Text));
									brOut.Write(int.Parse(displayHeight.Text));
									brOut.Write(int.Parse(displayDepth.Text));
									//write filedata
									brOut.Write(brIn.ReadBytes(length-16));
								}
								else
								{
									//write filedata
									brOut.Write(brIn.ReadBytes(length));
								}
							}
						}
					}
					brIn.Close();
					fsIn.Close();
				}
				else
				{
					//item is external file
					string name;
					name = items.Text;
					//write namelength
					brOut.Write(name.Length);
					//write name
					for (int i=0;i<name.Length;i++)
						brOut.Write(name[i]);
					//check if the fie is a .dll and if we need to upx it
					if (name.EndsWith(".dll") && chkCompress.Checked == true)
					{
						//copy dll to "___upx.dll"
						File.Copy(items.SubItems[2].Text, "___upx.dll");
						//compress with upx
						Process process = Process.Start(Application.StartupPath + "\\upx.exe",upx_options + " ___upx.dll");
						process.WaitForExit();
						//copy to output
						fsUpx = new FileStream("___upx.dll", FileMode.Open);
						brUpx = new BinaryReader(fsUpx);
						//write length
						brOut.Write((int) fsUpx.Length);
						//write filedata
						brOut.Write(brUpx.ReadBytes((int) fsUpx.Length));
						brUpx.Close();
						fsUpx.Close();
						//delete "___upx.dll"
						File.Delete("___upx.dll");
					}
					else
					{
						fsExt = new FileStream(items.SubItems[2].Text,FileMode.Open);
						brExt = new BinaryReader(fsExt);
						//write length
						brOut.Write((int)fsExt.Length);
						//check for "_virtual.dat" and use display settings
						if (name == "_virtual.dat")
						{
							//seek over display info
							fsExt.Seek(16,SeekOrigin.Current);
							//write display info
							brOut.Write(displayType.SelectedIndex);
							brOut.Write(int.Parse(displayWidth.Text));
							brOut.Write(int.Parse(displayHeight.Text));
							brOut.Write(int.Parse(displayDepth.Text));
							//write filedata
							brOut.Write(brExt.ReadBytes((int)fsExt.Length-16));
						}
						else
						{
							//write filedata
							brOut.Write(brExt.ReadBytes((int)fsExt.Length));
						}
						brExt.Close();
						fsExt.Close();
					}
				}
			}
			//close open files
			brOut.Close();
			fsOut.Close();
		}
		dlg.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:101,代码来源:main.cs

示例13: btnDecrypt_Click

	private void btnDecrypt_Click(object sender, EventArgs e)
	{
		//decrypt file
		FileStream fsIn;
		BinaryReader brIn;
		FileStream fsOut;
		BinaryWriter bwOut;
		OpenFileDialog dlg = new OpenFileDialog();
		dlg.Title = "Select file to decrypt";
		dlg.Filter = "All Files (*.*)|*.*";
		if (dlg.ShowDialog() == DialogResult.OK)
		{
			SaveFileDialog sDlg = new SaveFileDialog();
			sDlg.Title = "Save decrypted file as";
			sDlg.Filter = "Loaded file type (*"+Path.GetExtension(dlg.FileName)+")|*"+Path.GetExtension(dlg.FileName);
			sDlg.Filter += "|All Files (*.*)|*.*";
			if (sDlg.ShowDialog() == DialogResult.OK)
			{
				if (dlg.FileName == sDlg.FileName)
				{
					MessageBox.Show("Can't decrypt to input file!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
					dlg.Dispose();
					sDlg.Dispose();
					return;
				}
				else
				{
					byte input,xor;
					xor = 0x21;
					//xor = 0xDF;
					fsIn = new FileStream(dlg.FileName,FileMode.Open);
					brIn = new BinaryReader(fsIn);
					fsOut = new FileStream(sDlg.FileName,FileMode.Create);
					bwOut = new BinaryWriter(fsOut);

					int i = (int)(fsIn.Position - fsIn.Length);
					while ((int)(fsIn.Length - fsIn.Position) > 28)
					{
						input = brIn.ReadByte();
						input = (byte)(xor ^ input);
						bwOut.Write(input);
						bwOut.Write(brIn.ReadBytes(28));
					}
					if ((int)(fsIn.Length - fsIn.Position) > 0)
					{
						input = brIn.ReadByte();
						input = (byte)(xor ^ input);
						bwOut.Write(input);
					}
					if (fsIn.Position < fsIn.Length)
					bwOut.Write(brIn.ReadBytes((int)(fsIn.Length-fsIn.Position)));

					brIn.Close();
					fsIn.Close();
					bwOut.Close();
					fsOut.Close();
				}
			}
			sDlg.Dispose();

		}
		dlg.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:63,代码来源:main.cs

示例14: MenuItem19Click

        private void MenuItem19Click(object sender, EventArgs e)
        {
            if (Cameras.Count == 0 && Microphones.Count == 0)
            {
                MessageBox.Show(LocRM.GetString("NothingToExport"), LocRM.GetString("Error"));
                return;
            }

            var saveFileDialog = new SaveFileDialog
                                     {
                                         InitialDirectory = Program.AppPath,
                                         Filter = "iSpy Files (*.ispy)|*.ispy|XML Files (*.xml)|*.xml"
                                     };

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string fileName = saveFileDialog.FileName;

                if (fileName.Trim() != "")
                {
                    SaveObjects(fileName);
                }
            }
            saveFileDialog.Dispose();
        }
开发者ID:WesleyYep,项目名称:ispyconnect,代码行数:25,代码来源:MainForm.cs

示例15: build_Click


//.........这里部分代码省略.........

				//write num of internal files
				bwOut.Write((byte) Intern.Items.Count);

				//write each internal file to patch
				foreach (ListViewFileItem itm in Intern.Items)
				{
					//name
					bwOut.Write(itm.Text.Length);
					bwOut.Write(Encoding.ASCII.GetBytes(itm.Text));
					//data
					//check if file is in <exe> or not
					if (itm.SubItems[1].Text == "<exe>")
					{
						//in <exe>
						fsIn.Seek(itm.Offset, SeekOrigin.Begin);
						//size
						bwOut.Write(itm.Size);
						//data
						bwOut.Write(brIn.ReadBytes(itm.Size));
					}
					else
					{
						//external file
						//filedata
						fsExt = new FileStream(itm.SubItems[1].Text,FileMode.Open);
						brExt = new BinaryReader(fsExt);
						//size
						bwOut.Write((int) fsExt.Length);
						//data
						bwOut.Write(brExt.ReadBytes((int) fsExt.Length));
						brExt.Close();
						fsExt.Close();
					}
				}

				//use md5 checksums?
				if (CheckSum.Checked == true)
					bwOut.Write((byte) 1);
				else
					bwOut.Write((byte) 0);

				//write num of External files
				bwOut.Write((byte) Extern.Items.Count);
				string checksum;

				foreach (ListViewFileItem itm in Extern.Items)
				{
					//write name
					bwOut.Write(itm.Text.Length);
					bwOut.Write(Encoding.ASCII.GetBytes(itm.Text));
					
					//write md5 checksum string if needed
					if (CheckSum.Checked == true)
					{
						found = false;
						if (File.Exists(Plugins + itm.Text))
						{
							fsExt = new FileStream(Plugins + itm.Text,FileMode.Open);
							found = true;
						}
						if (File.Exists(Plugins_user + itm.Text))
						{
							fsExt = new FileStream(Plugins_user + itm.Text,FileMode.Open);
							found = true;
						}
						if (File.Exists(Effects + itm.Text))
						{
							fsExt = new FileStream(Effects + itm.Text,FileMode.Open);
							found = true;
						}
						if (found == true)
						{
							//get md5 checksum
							brExt = new BinaryReader(fsExt);
							System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
							byte[] result = md5.ComputeHash(brExt.ReadBytes((int)fsExt.Length));
							checksum = BitConverter.ToString(result).Replace("-","").ToLower();
							brExt.Close();
							fsExt.Close();
							//write md5 checksum
							bwOut.Write(Encoding.ASCII.GetBytes(checksum));
						}
					}
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.ToString(),"Error!",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			}
			finally
			{
				brIn.Close();
				fsIn.Close();
				bwOut.Close();
				fsOut.Close();
			}
		}
		dlg.Dispose();
	}
开发者ID:winch,项目名称:winch.pinkbile.com-c-sharp,代码行数:101,代码来源:main.cs


注:本文中的SaveFileDialog.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。