to sjc0(流浪者)
还是不行,我用的是VB,请再赐教

解决方案 »

  1.   

    加上using System.IO;
    VB中你加吧!再试!
      

  2.   

    请问加在.aspx中的哪个地方?
      

  3.   

    楼主看看这段代码,注意File.Exists()的使用方法,Imports System
    Imports System.IO
    Imports System.TextPublic Class Test
        Public Shared Sub Main()
            Dim path As String = "c:\temp\MyTest.txt"
            Dim path2 As String = path + "temp"
            Try
                Dim sw As StreamWriter = File.CreateText(path)
                sw.Close()
                ' Do the Copy operation only if the first file exists
                ' and the second file does not.
                If File.Exists(path) Then
                    If File.Exists(path2) Then
                        Console.WriteLine("The target file already exists.")
                    Else
                        'try to copy it
                        File.Copy(path, path2)
                        Console.WriteLine("{0} was copied to {1}.", path, path2)
                    End If
                Else
                    Console.WriteLine("The source file does not exist.")
                End If
            Catch e As Exception
                Console.WriteLine("The process failed: {0}", e.ToString())
            End Try
        End Sub
    End Class