I have an Azure web role and a separate computer. 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角色和一*立的计算机。它们都在同一个网络上,并且都共享另一个可以访问的特定文件夹。如果我使用我的Azure web角色,通过远程桌面,我可以使用\\comp1\文件夹和添加/删除/编辑文件到其他计算机的共享文件夹。
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角色上有一些图像文件需要复制到单独的计算机上。这些图像被上传到web角色并存储在那里。
How can I copy those images that are on the web role, to my other computer?
我怎么能把网络角色上的图像复制到我的另一台电脑上?
I have tried using File.Copy
but it always gives me Access Denied errors.
我试过使用文件。复制,但它总是给我访问拒绝错误。
I tried doing:
我试着做的事情:
File.Copy(Server.MapPath("~/image/a.jpg"),@"\\comp1\folder\b.jpg");
Result: UnauthorizedAccessException
结果:UnauthorizedAccessException
1 个解决方案
#1
1
I don't think you can access the file system on Azure like that, except through Local Storage?
我不认为你能像那样访问Azure上的文件系统,除了通过本地存储?
To quote Bill Wilder
引用比尔·怀尔德
Any of your code running in either (a) ASP.NET (e.g., default.aspx or default.aspx.cs) or (b) WebRole.cs/WorkerRole.cs (e.g., methods OnStartup, OnRun, and OnStop which are derived from RoleEntryPoint class) will not have permission to write to the file system.
任何运行在(a) ASP中的代码。净(如违约。aspx或default.aspx.cs)或(b) webroley .cs/WorkerRole。cs(例如,从RoleEntryPoint类派生的OnStartup、OnRun和OnStop方法)将没有写入文件系统的权限。
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存储。
阅读更多:http://www.intertech.com/Blog/Post/Windows-Azure-Local-File-Storage-How-To-Guide-and-Warnings.aspx # ixzz26ce8rXpk
#1
1
I don't think you can access the file system on Azure like that, except through Local Storage?
我不认为你能像那样访问Azure上的文件系统,除了通过本地存储?
To quote Bill Wilder
引用比尔·怀尔德
Any of your code running in either (a) ASP.NET (e.g., default.aspx or default.aspx.cs) or (b) WebRole.cs/WorkerRole.cs (e.g., methods OnStartup, OnRun, and OnStop which are derived from RoleEntryPoint class) will not have permission to write to the file system.
任何运行在(a) ASP中的代码。净(如违约。aspx或default.aspx.cs)或(b) webroley .cs/WorkerRole。cs(例如,从RoleEntryPoint类派生的OnStartup、OnRun和OnStop方法)将没有写入文件系统的权限。
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存储。
阅读更多:http://www.intertech.com/Blog/Post/Windows-Azure-Local-File-Storage-How-To-Guide-and-Warnings.aspx # ixzz26ce8rXpk