如何在SaveFileDialog中使用复选框选项作为只读? [英] How to Use a checkbox option as readonly in SaveFileDialog ?
本文介绍了如何在SaveFileDialog中使用复选框选项作为只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个 SaveFileDialog
框,其中包含 CheckBox
选项,只读或不是
我有一个事件按钮的代码
I would like to make a SaveFileDialog
box with a CheckBox
option for read only or not
I have this code for a event button
private void button1_Click(object sender, EventArgs e)
{
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = saveFileDialog1.OpenFile()) != null)
{
// Code to write the stream goes here.
myStream.Close();
}
}
}
推荐答案
您可以使用只读选项OpenFileDialog
,而非SaveFileDialog
。
http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.readonlychecked.aspx [ ^ ]
You can use read only option inOpenFileDialog
, notSaveFileDialog
.
http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.readonlychecked.aspx[^]
SaveFileDialog
没有ReadOnly
并且它使没意思,因为你想保存一个文件,你不能写入只读文件。
你需要使用OpenFileDialog
,其中包含ShowReadOnly
属性,您可以将其设置为True
。
SaveFileDialog
has noReadOnly
and it makes no sense as you want to save a file, and you can't write to a read-only file.
You need to use theOpenFileDialog
which has aShowReadOnly
property which you can set toTrue
.
那么这可能是什么解决方案呢?制作我自己的SaveFileDialog
So what could be the solution for this ? Making my Own SaveFileDialog
这篇关于如何在SaveFileDialog中使用复选框选项作为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文