ورود

View Full Version : موقع UpLoad از مسیرم ایراد میگیره



Blackk_lightt
سه شنبه 12 شهریور 1387, 18:05 عصر
سلام
من تو هاستم یه پوشه به نام Test دارم
میخوام کاربر فایلاشو توی اون UpLoad کنه
این کدمه :


if (FileUpload1.HasFile) FileUpload1.SaveAs("/test/a.a");


ولی از مسیری که دادم ایراد میگیره:


Could not find a part of the path 'c:\test\a.a'.


اگه میشه یکی کمکم کنه:گریه::گریه::گریه:

salehbagheri
سه شنبه 12 شهریور 1387, 18:20 عصر
برادر عزيز! اولا پوشه شما بايد Exits باشه يعني موجود باشه! دوماً به اين صورت نبايد آدرس بدي!
به كد زير توجه كن:


Protected Sub btnAllUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAllUpload.Click
If AllFU.HasFile Then
If (AllFU.PostedFile.ContentLength / 1024) > 50 Then
lblAllSuccess.Text = "Size of Selected File is greater than 50K!"
lblAllSuccess.Visible = True
Exit Sub
End If
Dim Folder1, Folder2 As String
Folder1 = Server.MapPath("Others\Uploads\") & DateTime.Now.Month.ToString & "\" & DateTime.Now.ToLongDateString & "\Time(" & DateTime.Now.Hour.ToString & "," & DateTime.Now.Minute.ToString & ")"
Folder2 = "Others/Uploads/" & DateTime.Now.Month.ToString & "/" & HttpUtility.UrlEncode(DateTime.Now.ToLongDateStrin g) & "/Time(" & DateTime.Now.Hour.ToString & "," & DateTime.Now.Minute.ToString & ")/"
Dim SourceDir As New DirectoryInfo(Folder1)
If Not (SourceDir.Exists) Then
SourceDir.Create()
End If
AllFU.SaveAs(Folder1 + "\" + AllFU.FileName)
lblAllSuccess.Text = "Your file was saved in: <br /><a href=""" + Folder2 + AllFU.FileName + """>Your File</a>"
lblAllSuccess.Visible = True
End If
End Sub