C#winfrom中SaveFileDialog控件如何自动保存到指定的路径

如题所述

第1个回答  2011-07-12
//自动保存图片的代码
private void Autosave()
{
string Opath =@"D:\VedioCapture\Photo";
string photoname = DateTime.Now.Ticks.ToString();
if (Opath.Substring(Opath.Length-1, 1) != @"\")
Opath = Opath + @"\";
string path1 = Opath + DateTime.Now.ToShortDateString();
if (! Directory.Exists(path1))
Directory.CreateDirectory(path1);
//pictureBox1.Image.Save(path1 +"\\" + photoname + ".jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
//图像的缩小
System.Drawing.Bitmap objPic,objNewPic;
try
{
objPic = new System.Drawing.Bitmap(pictureBox1.Image);
objNewPic=new System.Drawing.Bitmap(objPic,pictureBoxShow.Width,pictureBoxShow.Height);
//objNewPic=new System.Drawing.Bitmap(objPic,320,240);//图片保存的大小尺寸
objNewPic.Save(path1 +"\\" + photoname + ".jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch(Exception exp){throw exp;}
finally
{
objPic=null;
objNewPic=null;
}
}
第2个回答  推荐于2016-01-13
另存为 功能?
private void TSMISaveOthers_Click(object sender, EventArgs e)//另存为
{
//SFDSave为控件名
SFDSave.ShowDialog();
string path = SFDSave.FileName;
FileStream FS = new FileStream(path, FileMode.Create);
StreamWriter SW = new StreamWriter(FS);
SW.Write(txtContext.Text );
SW.Close();
FS.Close();
}本回答被提问者采纳
第3个回答  2011-07-12
SaveFileDialog只是让用户选路径而已, 保存方法有对象自身实现
自动保存不需要这个控件, 直接调用保存方法即可
第4个回答  2011-07-13
有OpenFileDialog对话框和SaveFileDialog
一个打开文件,一个保存啊/
你知道吗?还是你有另外的意见?
需要代码的话我给你弄一下/
发个邮箱,或者地址给我。
第5个回答  2011-07-12
什么意思?是对话框打开时默认路径?还是自动保存?追问

自动保存 连对话框都不出现的那种

追答

对话框有属性,设置默认路径属性与文件名属性,还有扩展名属性,最后将对话框的DialogResult属性设置成DialogResult.OK,调用对话框的Save方法

追问

给点代码提示下

追答

我现在电脑上没有.net开发环境,等晚上了给你代码吧

追问

恩谢谢了

相似回答