Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

c# - Could not find a part of the path on windows azure

I deployed mvc-3 application on windows azure. In my application i am uploading the file an save it in the App_Data/DownloadedTemplates folder.

  var path = Server.MapPath("~App_Data/DownloadedTemplates");

my application is running on staging environment currently. When i uploaded file , it shows me an exception in the browser :

Could not find a part of the path 'F:sitesrootApp_DataDownloadedTemplatesB.htm_2c77cdfd-c597-4234-bd1e-29ca0a9b8d0e.htm'.

I am using Server.MapPath to locate the path of App_Data on the server, now why this exception ?. Can anybody tell me the problem ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You shouldn't be doing this in a Windows Azure application. In Windows Azure you should use LocalResources (reserved space on a dedicated disk) for saving temp files on the disk, this is the only place where you should store data.

Here is an example of how you would access such a LocalResource (name and size can be configured in the VS project):

LocalResource localResource = RoleEnvironment.GetLocalResource("DownloadedTemplates");

Don't forget that data in LocalResources might disappear (when the machine crashes for example). If you really want to persist your data, you should be using Windows Azure Blob Storage.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...