SharePoint2007WebサイトでラップされたASP.NETアプリケーションがあります。このアプリケーション内で、ユーザーがリクエストを作成できるようにし、リクエストのサポートファイルをアップロードすることもできます。ユーザーがタイプ.docxまたは.xlsx(これまでに破損していることがわかった2つだけ)のサポートドキュメントをアップロードすると、それらを開こうとすると、プロンプトが表示されるという意味で「破損」します。メッセージ:
「Excelが「Book1.xlsx」で読み取り不可能なコンテンツを検出しました。このワークブックのコンテンツを復元しますか?このワークブックのソースを信頼できる場合は、[はい]をクリックしてください。」
[はい]をクリックすると、ファイルが修復され、内容が正しく表示されますが、これはユーザーには受け入れられません。私は彼らに問題を起こさせたくありません。
アップロードクリックイベントのコード(VB.NET)は次のとおりです。
Private Sub Upload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Try
Dim currentUser As SPUser = SPContext.Current.Web.AllUsers("SHAREPOINT\SYSTEM")
Dim currentUserToken As SPUserToken = currentUser.UserToken
Using currentSite As SPSite = New SPSite(SPContext.Current.Web.Url, currentUserToken)
Using CurrentWeb As SPWeb = currentSite.OpenWeb
CurrentWeb.AllowUnsafeUpdates = True
Dim attachmentList As SPList = CurrentWeb.Lists("Requests")
Dim item As SPListItem = attachmentList.GetItemById(CurrentRequestId)
If FileUpload.PostedFile.ContentLength > Nothing And FileUpload.HasFile Then
Dim fStream As Stream = FileUpload.PostedFile.InputStream
Dim contents() As Byte = New Byte(fStream.Length) {}
fStream.Read(contents, 0, CType(fStream.Length, Integer))
fStream.Close()
fStream.Dispose()
Dim attachments As SPAttachmentCollection = item.Attachments
Dim fileName As String = Path.GetFileName(FileUpload.PostedFile.FileName)
attachments.Add(fileName, contents)
item.Update()
Else
Page.ClientScript.RegisterStartupScript(Page.GetType(), "disp_msg", "<script type='text/javascript'>alert('The file contains 0 Bytes of data and will be deleted.'); </script>")
End If
End Using
End Using
DisplayAttachment(CurrentRequestId)
btnSave.Focus()
Catch ex As Exception
Page.ClientScript.RegisterStartupScript(Page.GetType(), "disp_msg", "<script type='text/javascript'>alert('Error Uploading File: " & ex.Message & "'); </script>")
End Try
End Sub
どんな助けでもいただければ幸いです。前もって感謝します。