我正在使用此代码在我的应用中保存文件
Dim filePath = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now)
PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filePath)))
所以现在我有一个textbox1,我想在其中显示上次保存图像的路径 如何?
此致,,,,
答案 0 :(得分:1)
我过去所做的是一步生成路径,然后使用生成的变量进行保存并显示。
所以而不是:
Dim filePath = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now)
PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filePath)))
尝试:
'Generate the Path
Dim path As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now))
'Save using the generated path
PictureBox1.Image.Save(path)
'Display the path
textbox1.Text = path
答案 1 :(得分:0)
感谢所有我成功完成的事情
Dim filename As String = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now)
Dim filePath1 = (IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filename)))
Dim filePath2 = (IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), ("RMSS")))
If IO.Directory.Exists(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (" RMSS"))) = True Then
TextBox1.Text = filePath1
TextBox2.Text = filePath2 & "\" & filename
PictureBox1.Image.Save(filePath1)
My.Computer.FileSystem.MoveFile(TextBox1.Text, TextBox2.Text, True)
Else
TextBox1.Text = filePath1
TextBox2.Text = filePath2 & "\" & filename
PictureBox1.Image.Save(filePath1)
My.Computer.FileSystem.MoveFile(TextBox1.Text, TextBox2.Text, True)
End If