在我的 Web 应用程序中,我必须将文件从用户计算机移动到服务器。我必须使用 ascx 组件来执行此操作。
这是代码:
Private Function FileReplciate(ByRef FilePath As String)
'FilePath is the full file path e.g C:/Program Files/file.txt
' Create an id to hide the original file name (for security)
Dim id = New Guid;
Try
'Here I move the file using File.Move() here is the error
File.Move(FilePath, Server.MapPath("temp\" & id.ToString))
Catch ex As exception
End Try
End Function
因此,当源文件位于“MyDocuments”或“MyPictures”之类的文件夹或“User”文件夹内的任何子文件夹中时,我收到拒绝访问错误。
当源文件位于“C:\”或“C:\ProgramFiles”等文件夹中时,我不会收到此错误。