本文整理汇总了VB.NET中System.IO.File.Replace方法的典型用法代码示例。如果您正苦于以下问题:VB.NET File.Replace方法的具体用法?VB.NET File.Replace怎么用?VB.NET File.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.File
的用法示例。
在下文中一共展示了File.Replace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: FileExample
' 导入命名空间
Imports System.IO
Module FileExample
Sub Main()
Try
Dim OriginalFile As String = "test.xml"
Dim FileToReplace As String = "test2.xml"
Dim BackUpOfFileToReplace As String = "test2.xml.bac"
Console.WriteLine("Move the contents of " + OriginalFile + " into " + FileToReplace + ", delete " + OriginalFile + ", and create a backup of " + FileToReplace + ".")
' Replace the file.
ReplaceFile(OriginalFile, FileToReplace, BackUpOfFileToReplace)
Console.WriteLine("Done")
Catch e As Exception
Console.WriteLine(e)
End Try
Console.ReadLine()
End Sub
' Move a file into another file, delete the original, and create a backup of the replaced file.
Sub ReplaceFile(ByVal FileToMoveAndDelete As String, ByVal FileToReplace As String, ByVal BackupOfFileToReplace As String)
' Replace the file.
File.Replace(FileToMoveAndDelete, FileToReplace, BackupOfFileToReplace, False)
End Sub
End Module