How to rename files in VB.NET to have a unique suffix?

后端 未结 5 1919
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 20:01

I understand how to rename a file in VB.NET as I use in the code at the end of my post. However, I was wondering if it\'s possible to rename a file and if the file exists th

5条回答
  •  时光取名叫无心
    2020-12-06 20:27

    You need to write your own logic for this.

    The File class has many useful method for dealing with files.

    If File.Exists(filePath) Then
      ' Give a new name
    Else
      ' Use existing name
    End If
    

    The Path class has many methods for dealing with file paths.

    Path.GetFileNameWithoutExtension(filePath)
    

提交回复
热议问题