您的位置:首页 > 编程语言 > C#

Windows编程中上传图片的C#代码

2008-03-25 18:56 507 查看
 


openFileDialog1.Filter = "*.jpg(JPG图片)|*.jpg|*.gif(gif图片)|*.gif";


    if (openFileDialog1.ShowDialog() == DialogResult.OK)




            ...{


                string sourceFileName = openFileDialog1.FileName;


                int nLength = sourceFileName.Length - sourceFileName.LastIndexOf("/") - 1;


                FileName = sourceFileName.Substring(sourceFileName.LastIndexOf("/") + 1, nLength);


                string destFileName = Application.StartupPath + @"pic" + FileName;


                System.IO.File.Copy(sourceFileName, destFileName);


                pictureBox1.Image = Image.FromFile(destFileName);


}



 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  windows 编程 c# string