Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何获取文件';由该代码创建的路径?_Vb.net_File_Path_Save - Fatal编程技术网

Vb.net 如何获取文件';由该代码创建的路径?

Vb.net 如何获取文件';由该代码创建的路径?,vb.net,file,path,save,Vb.net,File,Path,Save,我正在使用此代码在我的应用程序中保存文件 Dim filePath = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now) PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filePath))) 现在我有了一个textbox1,我想显示最后保存的图像的路径 怎么做

我正在使用此代码在我的应用程序中保存文件

 Dim filePath = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now)
    PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filePath)))
现在我有了一个textbox1,我想显示最后保存的图像的路径 怎么做


关于,,,

我过去所做的是一步生成路径,然后使用生成的变量进行保存和显示

因此,不是:

Dim filePath = String.Format("image{0:yyyyMMddHHmmss}.png", DateTime.Now)
PictureBox1.Image.Save(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (filePath)))
尝试:


谢谢你,我做得很成功`

  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

大概,
TextBox1.Text=IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),filePath)
Great Mike_OBrien先生可以工作,但如果我想先在桌面上创建文件夹,然后将图像保存在那个文件夹中,该怎么办?@user206402:你真的应该自己做一些研究:
  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