2010-05-13 3 views
4

IO.File.Copy 메서드는 파일 특성을 보존합니까? 특히 쓰기 금지 된 파일이있는 경우 해당 복사본을 쓰기 금지로 보호합니까?IO.File.Copy는 파일 특성을 복제합니까?

+0

난 아직 대답은 확신 "아니오"라고 대답하지만 답변을 철회하고 대답을 뒷받침하는 문서를 보여줄 수있는 사람에게 점수를 제공 할 것입니다. – David

답변

4

다음 코드는 파일 특성이 복사되었음을 증명합니다.

Dim sourceFile = "z.txt" 
    Dim destinationFile = "x.txt" 

    Using sw As IO.StreamWriter = IO.File.CreateText(sourceFile) 
     sw.Write("testing") 
    End Using 

    IO.File.SetAttributes(sourceFile, IO.FileAttributes.ReadOnly) 
    Debug.WriteLine("Source File ReadOnly = " & (IO.File.GetAttributes(sourceFile) And IO.FileAttributes.ReadOnly)) 

    IO.File.Copy(sourceFile, destinationFile) 
    Debug.WriteLine("Destination File ReadOnly = " & (IO.File.GetAttributes(destinationFile) And IO.FileAttributes.ReadOnly)) 

그리고 단지 IO.File.Copy가 복사됩니다 어떤 문서를 가지고 무엇을 KERNEL32.DLL의 CopyFile 수 기능을 사용하는 내가 볼 리플렉터를 사용하는 데이되지 않습니다 : http://msdn.microsoft.com/en-us/library/aa363851(VS.85).aspx

관련 문제