在我的asp.net頁面中,我製作了一個從本地驅動器到服務器的文件副本。目錄未找到異常...但我可以瀏覽到目錄?
'append the name to the id number and generate the file name
strFileName = System.Configuration.ConfigurationManager.AppSettings("strAttachmentsPath") & l.ToString & "_" & CType(Session("FileName"), String)
'upload the file
'FileUpload1.SaveAs(strFileName)
System.IO.File.Copy(CType(Session("Attachment"), String), strFileName, True)
strFileName
包含像"\\myServer\images\theNewFileName.jpg"
Session("Attachment")
服務器路徑包含我的本地路徑'C:\Users\myUser\Desktop\AccountsFrance.txt'
但是當我運行此代碼asp.net拋出一個異常:
但我可以瀏覽到這個文件很容易.... 我不明白爲什麼會發生這種情況:(
這很可能是一個權限問題。或者,您正在使用不同的文件路徑,那麼您的真正意圖。 – 2011-05-03 16:32:29
@ rlb.usa - 不知道如何解決這個問題......因爲我無法設置fileupload控件爲了安全起見而採取字符串編程方式。我需要允許最終用戶將文件從一個路徑複製到服務器。該路徑可能是他們的本地PC C/D/E驅動器等... – oJM86o 2011-05-03 16:34:30