Windows编程中上传图片的C#代码
2008-03-25 18:56
507 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
openFileDialog1.Filter = "*.jpg(JPG图片)|*.jpg|*.gif(gif图片)|*.gif";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
if (openFileDialog1.ShowDialog() == DialogResult.OK)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string sourceFileName = openFileDialog1.FileName;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int nLength = sourceFileName.Length - sourceFileName.LastIndexOf("/") - 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
FileName = sourceFileName.Substring(sourceFileName.LastIndexOf("/") + 1, nLength);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string destFileName = Application.StartupPath + @"pic" + FileName;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.IO.File.Copy(sourceFileName, destFileName);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pictureBox1.Image = Image.FromFile(destFileName);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- 从Windows系统下访问Linux分区相关软件
- Windows XP最新应用技巧大荟萃
- Windows 系统组策略应用全攻略(上)第1/2页
- DB2编程序技巧(1)
- DB2编程序技巧 (四)
- DB2编程序技巧 (六)
- DB2编程序技巧 (三)
- DB2编程序技巧 (九)
- DB2编程序技巧 (七)
- DB2编程序小小技巧
- DB2编程序技巧 (五)
- Microsoft Windows Vista 简体中文企业版 MVL DVD IMG 32-bit(1.9GB)
- Windows Vista下去除QQ和MSN广告的方法
- Windows Vista 宽屏LCD提供的支持 与设置方法第1/2页
- DB2编程序技巧 (一)
- DB2编程序技巧 (八)
- DB2编程序技巧 (十)
- Windows 系统组策略应用全攻略(下)第1/3页
- VBS基础编程教程 (第1篇)