本文整理汇总了C#中System.Windows.Forms.OpenFileDialog.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# OpenFileDialog.ToString方法的具体用法?C# OpenFileDialog.ToString怎么用?C# OpenFileDialog.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.OpenFileDialog
的用法示例。
在下文中一共展示了OpenFileDialog.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenFileDialogTest
public void OpenFileDialogTest ()
{
ofd = new OpenFileDialog ();
Assert.IsTrue (ofd.AddExtension, "#11");
Assert.IsTrue (ofd.CheckFileExists, "#12");
Assert.IsTrue (ofd.CheckPathExists, "#13");
Assert.AreEqual ("", ofd.DefaultExt, "#14");
Assert.IsTrue (ofd.DereferenceLinks, "#15");
Assert.AreEqual ("", ofd.FileName, "#16");
Assert.IsNotNull (ofd.FileNames, "#17");
Assert.AreEqual (0, ofd.FileNames.Length, "#17a");
Assert.AreEqual ("", ofd.Filter, "#18");
Assert.AreEqual (1, ofd.FilterIndex, "#19");
Assert.AreEqual ("", ofd.InitialDirectory, "#20");
Assert.IsFalse (ofd.Multiselect, "#21");
Assert.IsFalse (ofd.ReadOnlyChecked, "#22");
Assert.IsFalse (ofd.RestoreDirectory, "#23");
Assert.IsFalse (ofd.ShowHelp, "#24");
Assert.IsFalse (ofd.ShowReadOnly, "#25");
Assert.AreEqual ("", ofd.Title, "#26");
Assert.IsTrue (ofd.ValidateNames, "#27");
Assert.AreEqual ("System.Windows.Forms.OpenFileDialog: Title: , FileName: ", ofd.ToString (), "#28");
ofd.DefaultExt = ".TXT";
Assert.AreEqual ("TXT", ofd.DefaultExt, "#29");
ofd.Filter = null;
Assert.AreEqual ("", ofd.Filter, "#30");
ofd.Filter = "Text (*.txt)|*.txt|All (*.*)|*.*";
try {
ofd.Filter = "abcd";
} catch (Exception) {
}
Assert.AreEqual ("Text (*.txt)|*.txt|All (*.*)|*.*", ofd.Filter, "#30a");
ofd.FilterIndex = 10;
Assert.AreEqual (10, ofd.FilterIndex, "#30aa");
ofd.Filter = null;
Assert.AreEqual ("", ofd.Filter, "#30b");
Assert.AreEqual (10, ofd.FilterIndex, "#30ba");
string current_path = Environment.CurrentDirectory;
string current_file = Path.Combine(current_path, "test_file");
if (!File.Exists (current_file))
File.Create (current_file);
ofd.FileName = current_file;
Assert.AreEqual (current_file, ofd.FileName, "#31");
string[] file_names = ofd.FileNames;
Assert.AreEqual (current_file, file_names [0], "#32");
ofd.Title = "Test";
Assert.AreEqual ("System.Windows.Forms.OpenFileDialog: Title: Test, FileName: " + current_file, ofd.ToString (), "#33");
ofd.FileName = null;
Assert.AreEqual ("", ofd.FileName, "#33a");
Assert.IsNotNull (ofd.FileNames, "#33b");
Assert.AreEqual (0, ofd.FileNames.Length, "#33c");
ofd.Reset ();
// check again
Assert.IsTrue (ofd.AddExtension, "#34");
Assert.IsTrue (ofd.CheckFileExists, "#35");
Assert.IsTrue (ofd.CheckPathExists, "#36");
Assert.AreEqual ("", ofd.DefaultExt, "#37");
Assert.IsTrue (ofd.DereferenceLinks, "#38");
Assert.AreEqual ("", ofd.FileName, "#39");
Assert.IsNotNull (ofd.FileNames, "#40");
Assert.AreEqual ("", ofd.Filter, "#41");
Assert.AreEqual (1, ofd.FilterIndex, "#42");
Assert.AreEqual ("", ofd.InitialDirectory, "#43");
Assert.IsFalse (ofd.Multiselect, "#44");
Assert.IsFalse (ofd.ReadOnlyChecked, "#45");
Assert.IsFalse (ofd.RestoreDirectory, "#46");
Assert.IsFalse (ofd.ShowHelp, "#47");
Assert.IsFalse (ofd.ShowReadOnly, "#48");
Assert.AreEqual ("", ofd.Title, "#49");
Assert.IsTrue (ofd.ValidateNames, "#50");
Assert.AreEqual ("System.Windows.Forms.OpenFileDialog: Title: , FileName: ", ofd.ToString (), "#60");
}