使用服务器路径在远程服务器上复制文件时出错

时间:2012-06-06 21:44:41

标签: asp.net vb.net

我正在尝试将上传文件复制到远程服务器我得到以下异常。 复制100kb文件需要5分钟。

System.Threading.ThreadAbortException: Thread was being aborted.
   at Microsoft.Win32.Win32Native.CreateFile(String lpFileName, Int32 dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile)
   at Microsoft.Win32.Win32Native.SafeCreateFile(String lpFileName, Int32 dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.Net.Mail.AttachmentBase.SetContentFromFile(String fileName, String mediaType)
   at System.Net.Mail.Attachment..ctor(String fileName)
   at AFI.WarrantyClaim.SendConfirmationMail(String sClaimID, String sRecepient, Boolean bIsCust, ArrayList alUploadedFiles)
   at AFI.WarrantyClaim.btnNext_Click(Object sender, EventArgs e) 

导致此问题的代码:

For i As Integer = 0 To Request.Files.Count - 1
            Dim hpfFile As HttpPostedFile = Request.Files(i)

            If hpfFile.ContentLength > 0 Then
                Dim sFileExtention As String = System.IO.Path.GetExtension(hpfFile.FileName)
                Dim sFileName As String = String.Empty

                sFileName = sClaimNo + "_" + System.IO.Path.GetFileNameWithoutExtension(hpfFile.FileName) + "_" + iPhoto.ToString() + _
                            sFileExtention

                Dim sScopeIdentity As String = SaveImageData(Convert.ToInt32(sClaimNo), Convert.ToString(iPhoto), sFileName)
                hpfFile.SaveAs(ConfigurationManager.AppSettings(m_sUPLOADED_FILE_PATH) + sFileName)


               iPhoto = iPhoto + 1
            End If
        Next

1 个答案:

答案 0 :(得分:0)

看起来操作正在超时....检查PC上的防火墙设置,或检查远程服务器上的日志。