8 个解决方案
#1
File.Copy(要复制的文件, 目标文件的名称。不能是目录, true);
如:
File.Copy(@"c:\a.jpg", @"d:\b.jpg", true);
如:
File.Copy(@"c:\a.jpg", @"d:\b.jpg", true);
#3
试过,正确无误。
#4
直接调用用copy()函数啊
#5
用copy to
#6
copy to...流的基本属性方法 LZ得多看看书。。
#7
Imports System
Imports System.IO
Public Class Test
Public Shared Sub Main()
' Specify the directories you want to manipulate.
Dim path As String = "c:\temp\MyTest.txt"
Dim path2 As String = path + "temp"
Try
Dim fs As FileStream = File.Create(path)
fs.Close()
' Ensure that the target does not exist.
File.Delete(path2)
' Copy the file.
File.Copy(path, path2)
Console.WriteLine("{0} copied to {1}", path, path2)
' Try to copy the same file again, which should succeed.
File.Copy(path, path2, True)
Console.WriteLine("The second Copy operation succeeded, which was expected.")
Catch
Console.WriteLine("Double copying is not allowed, which was not expected.")
End Try
End Sub
End Class
#8
#1
File.Copy(要复制的文件, 目标文件的名称。不能是目录, true);
如:
File.Copy(@"c:\a.jpg", @"d:\b.jpg", true);
如:
File.Copy(@"c:\a.jpg", @"d:\b.jpg", true);
#2
#3
试过,正确无误。
#4
直接调用用copy()函数啊
#5
用copy to
#6
copy to...流的基本属性方法 LZ得多看看书。。
#7
Imports System
Imports System.IO
Public Class Test
Public Shared Sub Main()
' Specify the directories you want to manipulate.
Dim path As String = "c:\temp\MyTest.txt"
Dim path2 As String = path + "temp"
Try
Dim fs As FileStream = File.Create(path)
fs.Close()
' Ensure that the target does not exist.
File.Delete(path2)
' Copy the file.
File.Copy(path, path2)
Console.WriteLine("{0} copied to {1}", path, path2)
' Try to copy the same file again, which should succeed.
File.Copy(path, path2, True)
Console.WriteLine("The second Copy operation succeeded, which was expected.")
Catch
Console.WriteLine("Double copying is not allowed, which was not expected.")
End Try
End Sub
End Class