
1.创建一个项目,默认窗体为Form1
2.在Form1窗体中添加OpenFileDialog控件,添加一个TextBox控件用来显示打开的文件完全路径,添加4个CheckBox控件用来让用户选择文件的属性,添加3个Button控件分别用来打开文件,修改属性和关闭窗体.
3.主要程序代码:
private
void
button1_Click(object
send,EventArgs
e)
{
this.openFileDialog1.ShowDialog()
textBox1.Text=openFileDialog1.FileName
}
private
void
button2_Click(object
send,EventArgs
e)
{
System.IO.FileInfo
f=new
System.IO.FileInfo(textBox1.Text)
if(checkBox1.Checked)
{
//根据用户的选择文件的属性
f.Attributes=System.IO.FileAttributes.ReadOnly
}
if(checkBox2.Checked)
{
f.Attributes=System.IO.FileAttributes.System
}
if(checkBox3.Checked)
{
f.Attributes=System.IO.FileAttributes.Archive
}
if(checkBox4.Checked)
{
f.Attributes=System.IO.FileAttributes.Hidden
}
}
参考上面的看看,也可以试试下面的方法
System.Diagnostics.Process
p=new
System.Diagnostics.Process()
p.StartInfo.FileName=
"cmd
"
p.StartInfo.CreateNoWindow=true
p.StartInfo.UseShellExecute=false
p.StartInfo.RedirectStandardInput=true
p.Start()
p.StandardInput.WriteLine(
"attrib
*.*
-s
-h
")
p.StandardInput.WriteLine(
"exit
")
p.WaitForExit()
我这里有个办法,需要注意的是:我不确定这个方法是否适合所有人,但还是挖个坟替你解答一下吧。当时出现这个问题时,不仅导出JPG会出现这个问题,就连导PNG都会出现“无法完成请求,因为程序错误”的提示,通常发生这种情况是因为某个图层,或者是文字方面出现了一些未知问题导致的。你要做的事很简单:就是把你保存好的源文件复制一份,这时候你会得到两份一模一样的源文件,然后打开其中一个合并里面的所有图层在导图试试看能不能成功。欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)