SaveFileDialog操作只读属性的txt
SaveFileDialog不能覆盖只读属性的txt文本吗? 我保存就提示 该文件已设置为只读. 请使用其他文件名重试? 请问下有什么办法可以覆盖相同名字的源文件? --------------------编程问答-------------------- 在不改动源文件属性的情况下, 用代码怎么实现? 我不通过程序来copy覆盖文件,又是可以的..求高手指导下 --------------------编程问答-------------------- System.IO.File.SetAttributes,将文件只读属性去掉 --------------------编程问答-------------------- System.IO.File.SetAttributes,将文件只读属性去掉 ,改完后重新用System.IO.File.SetAttributes设为只读 --------------------编程问答--------------------System.IO.File.SetAttributes(this.label4.Text, System.IO.FileAttributes.Hidden);?
this.label4.Text 是源文件路径
没有用啊,还是提示该文件已设置为只读. 请使用其他文件名重试 --------------------编程问答--------------------
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = " ICT File(*.dat)|*.dat";
sfd.FileName = fileName;
//System.IO.File.SetAttributes;//
System.IO.File.SetAttributes(this.label4.Text, System.IO.FileAttributes.Normal);
//设置另存为bat文件
try
{
if (sfd.ShowDialog() == DialogResult.OK)
{
string filename = sfd.FileName;
StreamWriter sw = new StreamWriter(filename);
sw.WriteLine(txtValue);//读取需要保存的数据
sw.Flush();//写入
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
System.IO.File.SetAttributes怎么用的? --------------------编程问答-------------------- System.IO.File.SetAttributes(this.label4.Text, System.IO.FileAttributes.Normal);
第一次参数是要保存的路径? 而不是源文件的路径? --------------------编程问答-------------------- 留个脚印,学习下 --------------------编程问答--------------------
if (this.label3.Text == "")
{
MessageBox.Show("No Data!");
return;
}
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = " ICT File(*.dat)|*.dat";
sfd.FileName = fileName;
//设置另存为bat文件
try
{
if (sfd.ShowDialog() == DialogResult.OK)
{
string filename = sfd.FileName;
StreamWriter sw = new StreamWriter(filename);
sw.WriteLine(txtValue);//读取需要保存的数据
System.IO.File.SetAttributes(this.label4.Text, System.IO.FileAttributes.Normal);
sw.Flush();//写入
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
System.IO.File.SetAttributes(this.label4.Text, System.IO.FileAttributes.Normal);
为什么还是没去除只读属性呢? 还是覆盖不了
补充:.NET技术 , C#