[英]Copying a file from my Azure web role to another computer
I have an Azure web role and a separate computer. 我有一个Azure Web角色和一台单独的计算机。 Both of them are on the same network and both share certain folders which the other can access. 他们两个都在同一网络上,并且都共享某些文件夹,另一个可以访问。 If I go on my Azure web role, through remote desktop, I can go to the other computer's shared folder using \\\\comp1\\folder
and add/remove/edit files there. 如果我通过远程桌面担任Azure Web角色,则可以使用\\\\comp1\\folder
转到另一台计算机的共享文件\\\\comp1\\folder
然后在其中添加/删除/编辑文件。
I have a few image files on my web role which I need to copy to the separate computer. 我的网络角色上有一些图像文件,需要将其复制到另一台计算机上。 These images are uploaded to the web role and stored there. 这些图像将上载到Web角色并存储在其中。
How can I copy those images that are on the web role, to my other computer? 如何将那些在Web角色上的图像复制到另一台计算机上?
I have tried using File.Copy
but it always gives me Access Denied errors. 我尝试使用File.Copy
但它始终会给我“拒绝访问”错误。
I tried doing: 我试着做:
File.Copy(Server.MapPath("~/image/a.jpg"),@"\\comp1\folder\b.jpg");
Result: UnauthorizedAccessException
结果: UnauthorizedAccessException
I don't think you can access the file system on Azure like that, except through Local Storage? 除了通过本地存储,我不认为您可以像这样访问Azure上的文件系统?
To quote Bill Wilder 引用比尔·怀尔德(Bill Wilder)
Any of your code running in either (a) ASP.NET (eg, default.aspx or default.aspx.cs) or (b) WebRole.cs/WorkerRole.cs (eg, methods OnStartup, OnRun, and OnStop which are derived from RoleEntryPoint class) will not have permission to write to the file system. 您在(a)ASP.NET(例如default.aspx或default.aspx.cs)或(b)WebRole.cs / WorkerRole.cs(例如方法OnStartup,OnRun和OnStop中派生)中运行的任何代码(来自RoleEntryPoint类)将没有权限写入文件系统。
You can read and write to the Local Storage system 您可以读写本地存储系统
try
{
LocalResource myConfigsStorage = RoleEnvironment.GetLocalResource("myConfigs");
string s = System.IO.File.ReadAllText(myConfigStorage.RootPath + "myFile.txt");
//... do your work with s
}
catch (Exception myException)
{
... }
But having always used Azure with more than one instance I have never seen the need for local storage and used the blob store instead. 但是,始终将Azure与多个实例一起使用时,我从未见过需要本地存储,而是使用了Blob存储。
Read more: http://www.intertech.com/Blog/Post/Windows-Azure-Local-File-Storage-How-To-Guide-and-Warnings.aspx#ixzz26ce8rXpk 了解更多: http : //www.intertech.com/Blog/Post/Windows-Azure-Local-File-Storage-How-To-Guide-and-Warnings.aspx#ixzz26ce8rXpk
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.