简体   繁体   English

将文件从我的Azure Web角色复制到另一台计算机

[英]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.

相关问题 如何将IP地址绑定到我的Azure Web角色,以便远程计算机可以全局访问Web API? - How to bind an IP Address to my Azure Web Role so that the Web APIs can be accessed globally by a remote computer? 尝试将文件从我的计算机复制到同一网络上的另一台计算机 - Trying to copy a file from my computer to another computer on the same network 将本地数据库从一台计算机复制到另一台计算机 - Copying a local database from one computer to another 无法将文件从网络下载到计算机上的文件夹中 - Trouble downloading a file from the web to a folder on my computer 无法从我的程序写入另一台计算机上的XML文件 - Cannot write to XML file in another computer from my program 从一台计算机而不是另一台计算机部署时,C#Web应用程序在Azure中导致404错误 - C# web application causes 404 error in Azure when deployed from one computer, but not from another 从源代码管理部署Web角色到azure - deploy web role to azure from source control 从Azure Web角色,检查进程是否以辅助角色运行 - From Azure Web Role, check if a process is running in worker role Azure - 从Web角色中访问与worker角色相同的blob - Azure - Accessing the same blob from worker role as in web role 来自外部计算机的Azure上传文件 - Azure upload file from an external computer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM