Asp.net 如何在不使用fileupload控件的情况下将文件复制到aspx中的共享驱动器

Asp.net 如何在不使用fileupload控件的情况下将文件复制到aspx中的共享驱动器,asp.net,.net,vb.net,file-upload,Asp.net,.net,Vb.net,File Upload,我需要将文件从其他驱动器复制到网页中的共享驱动器。我无法使用FileUpload控件。我使用windowsIdentity进行复制。它在VS上工作,但在服务器上发布时工作。它显示找不到该文件。有人能告诉我该怎么办吗。谢谢 这是我的代码: Dim ImpersonateContext As WindowsImpersonationContext = Nothing Try ID = CType(User.Identity, WindowsIdentity) Impersonate

我需要将文件从其他驱动器复制到网页中的共享驱动器。我无法使用FileUpload控件。我使用windowsIdentity进行复制。它在VS上工作,但在服务器上发布时工作。它显示找不到该文件。有人能告诉我该怎么办吗。谢谢

这是我的代码:

Dim ImpersonateContext As WindowsImpersonationContext = Nothing

Try
    ID = CType(User.Identity, WindowsIdentity)
    ImpersonateContext = ID.Impersonate()

    System.IO.File.Copy("C:\Users\tester\Desktop\test.pdf, "\\sharedrive\temp\test.pdf")

Catch ex As System.Exception
    Throw New System.Exception(System.Security.Principal.WindowsIdentity.GetCurrent().Name & vbCrLf & ex.Message.ToString)
Finally
    If Not ImpersonateContext Is Nothing Then                       
        ImpersonateContext.Undo()
    End If
End Try

可以改进异常处理:不是捕获消息,而是将捕获的异常传递给构造函数,使其成为InnerException。假定C:\Users\tester\Desktop\test.pdf在本地计算机上?服务器上是否存在此文件?如果不是的话,很明显这是行不通的。。。