C#文件上传(textbox,button)
button点击选取图片,(可实现)将图片复制到指定路径,(未做到)textbox显示最新的图片路径(可实现)图片路径不能大于40个字节(未做到)我的字节是42个我的代码...
button点击选取图片,(可实现)将图片复制到指定路径,(未做到)textbox显示最新的图片路径(可实现)图片路径不能大于40个字节(未做到)我的字节是42个我的代码是这样的:private void button1_Click(object sender, EventArgs e) { OpenFileDialog file1 = new OpenFileDialog(); string picPath = Application.StartupPath + "\\1.gif"; file1.Filter = "文本文件|*.jpg"; textBox1.Text = null; file1.FileOk += File1_FileOk; file1.ShowDialog(); } private void File1_FileOk(object sender, CancelEventArgs e) { //转换类型 OpenFileDialog file1 = (OpenFileDialog)sender; string filename = file1.FileName; string oldfilename = filename.Substring(filename.Length - 13); string filenamenew = oldfilename.Replace(".post", ""); //string a = filename.Substring(filename.IndexOf(@""), filename.LastIndexOf(".")); textBox1.Text = @"C:\inetpub\wwwroot\EddPay\img\" + filenamenew + ".jpg"; }
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询