在我的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