2012-02-26 3 views
0

ASP.NET에서 VB 배경 코드로 양식을 만들었습니다. 내 문제는 내가 형태 에 의해 업로드되는 파일 대신 예를 들어 "Resemey.doc" "012 MaraCSD.doc"로 변경하는 것을 확인 할 것입니다업로드 한 파일의 이름을 바꾸는 방법은 무엇입니까?

약간의 연구를했고 나는 발견 내 VB 코드에 일부 코드를 추가해야합니다. 하지만 찾을 수 없습니다. 어디에 넣어야합니까?

'Add the namespace for the email-related classes 
Imports System.Net.Mail 

Partial Class SendAttachment  
    Inherits System.Web.UI.Page 

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click 
     'Make sure a file has been uploaded 

     If String.IsNullOrEmpty(AttachmentFile.FileName) OrElse AttachmentFile.PostedFile Is Nothing Then 
      Throw New ApplicationException("לא העלאת קבצים.") 
     End If 

     if AttachmentFile.PostedFile.ContentLength >600000 then 
      'display error file size should be less than 100kb 
     end if 


     '!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS 
     Const ToAddress As String = "[email protected]" 
     dim textMsg as String 
     textMsg ="שאלות סינון" & 
(vbCrLf) & (vbCrLf) & (vbCrLf) & question1.text & (vbCrLf) & q1.text & 
(vbCrLf) & (vbCrLf) & question2.text & (vbCrLf) & q2.text & 
(vbCrLf) & (vbCrLf) & question3.text & (vbCrLf) &q3.text & 
(vbCrLf) & (vbCrLf) & "ממליצים" & (vbCrLf) & c1.text & (Space(5)) & c2.text & (Space(5)) & c3.text & (vbCrLf) & 
(vbCrLf) & question4.text & (vbCrLf) & q5.text & (vbCrLf) & 
(vbCrLf) & "פרטים אישיים" & (vbCrLf) & 
(vbCrLf) & "שם מלא" & (vbCrLf) & pi1.text & (vbCrLf) & 
(vbCrLf) & "כתובת מייל" & (vbCrLf) & UsersEmail.Text & (vbCrLf) & 
(vbCrLf) & "טלפון" & (vbCrLf) & pi2.text & (vbCrLf) & 
(vbCrLf) &"שעות נוחות" & (vbCrLf) & pi3.text & (vbCrLf) & 
(vbCrLf) & (vbCrLf) & "הערות" & 
(vbCrLf) & body.text & (vbCrLf) & 
(vbCrLf) & "מעוניין בהצעות נוספות" & (vbCrLf) & q4.text 
' 

     '(1) Create the MailMessage instance 
     Dim mm As New MailMessage(UsersEmail.Text, ToAddress) 

     '(2) Assign the MailMessage's properties 
     mm.Subject = Subject.text & "-" & pi1.text 
     mm.Body = textMsg 

     mm.IsBodyHtml = false 

     'Attach the file 
     mm.Attachments.Add(New Attachment(AttachmentFile.PostedFile.InputStream, AttachmentFile.FileName)) 
     mm.Attachments.Add(New Attachment(AttachmentFile2.PostedFile.InputStream, AttachmentFile2.FileName)) 

     '(3) Create the SmtpClient object 
     Dim smtp As New SmtpClient 

     '(4) Send the MailMessage (will use the Web.config settings) 
     smtp.Send(mm) 

     'Show the EmailSentForm Panel and hide the EmailForm Panel 
     EmailSentForm.Visible = True 
     EmailForm.Visible = False 
    End Sub 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
     If Not Page.IsPostBack Then 
      'On the first page load, hide the EmailSentForm Panel 
      EmailSentForm.Visible = False 

     End If 
    End Sub 
End Class 

아이디어 :

이 내 코드?

+0

내가하는 System.IO.File를 참조합니다 :: 이동() 메소드 . http://msdn.microsoft.com/en-us/library/system.io.file.move.aspx – dubs

+0

시도해보십시오, dosent work – pelleg

+0

무엇이 작동하지 않습니까? 던져진 예외에 대한 예제 코드 및 세부 정보가 있습니까? – dubs

답변

관련 문제