C# winform 本地选择图片把路径上传到数据库,怎么把绝对地址装换成相对地址?
在picturebox下面有个选择本地的按钮,将在本地选择的图片显示在picturebox里面,将路径保存到数据库中,但保存的是绝对地址,怎么换成相对地址呢?
在picturebox下面有个选择本地的按钮,将在本地选择的图片显示在picturebox里面,将路径保存到数据库中,但保存的是绝对地址,怎么换成相对地址呢?
解决方案 »
- Windows移动游戏开发实战-使用C#语言.pdf
- 未能加载文件或程序集“PDFLibNet.dll”或它的某一个依赖项。找不到指定的模块。
- C# 页面一行数据时变形了,多行的时候不会?
- C#的OWC组件做出的曲线图问题!!
- 谁帮我进来看看这段代码 究竟什么问题?
- 100分求:如何检查远程文件是否存在?
- bcp倒入数据问题!---急,在线等!!!
- 急啊!mscomm
- 哪位知道关于RegSvr32.exe如何注册一个Dll的方法?
- Process调用其他程序EXE,如何进行排队处理
- Kill()杀不死360安全产品的进程,怎么办?【跪求高手】
- C# 如何达到photoshop用差值方法找两张图片不同的效果
(1)复制该文件到image (C# 把文件拷贝到指定文件夹 )
if(!System.IO.Directory.Exists(@"d:\你程序\imgage"))
{
// 目录不存在,建立目录
System.IO.Directory.CreateDirectory(@"d:\你程序\imgage");
}String sourcePath = "e:\\源文件目录\\图片文件";String targetPath = "d:\你程序\imgage";bool isrewrite=true; // true=覆盖已存在的同名文件,false则反之System.IO.File.Copy(sourcePath, targetPath, isrewrite);(2)得到本地路径文件
string fullNameNotExtName = System.Windows.Forms.Application.StartupPath.ToString() + "\\images" + 图片名称;
private void rmiAddPics_Click(object sender, System.EventArgs e)
{
System.Windows.Forms.OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "JPG files (*.JPG)|*.JPG|BMP files (*.BMP)|*.BMP" ;
openFileDialog.FilterIndex = 1 ;
string strFile ="";
string strDiy = "";
if(openFileDialog.ShowDialog() == DialogResult.OK)
{
strFile=openFileDialog.FileName.ToString();
string fullNameNotExtName=System.IO.Path.GetFileNameWithoutExtension(strFile); strDiy=System.IO.Path.GetDirectoryName(strFile);
//FileInfo fi = new FileInfo(strFile); System.Drawing.Image image = Image.FromFile(strFile);
this.pictureBox1.Image=image;
MemoryStream ms = new MemoryStream();
image.Save(ms,image.RawFormat);
byte[] serializedObject = ms.GetBuffer(); Imgname=this.comboBox1.Text=fullNameNotExtName.Trim();
Imgpath=strFile.Trim();
Imgcode=serializedObject; ms.Close(); this.comboBox1 .Enabled=false;
openFileDialog.OpenFile().Close();
openFileDialog.OpenFile().Flush();
}
}