Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 以编程方式下载Azure文件共享文档_C#_Asp.net_Azure_Fileshare_Azure Files - Fatal编程技术网

C# 以编程方式下载Azure文件共享文档

C# 以编程方式下载Azure文件共享文档,c#,asp.net,azure,fileshare,azure-files,C#,Asp.net,Azure,Fileshare,Azure Files,我参与的一个项目中,能够从Azure文件存储帐户下载文档(.pdf)将非常有用。这可能吗?我目前只能将目录和目录的文件内容路径作为字符串输出,但无法使用Microsoft.Azure命名空间访问这些路径上的文件 其他详细信息:在C#/ASP.NET中,作为Azure Web应用程序部署 多谢各位 是的,这是可能的 以下是一个演示,供您参考: 我的文件共享和一个图片文件如下: public static void DownloadFromFileStorage() {

我参与的一个项目中,能够从Azure文件存储帐户下载文档(.pdf)将非常有用。这可能吗?我目前只能将目录和目录的文件内容路径作为字符串输出,但无法使用Microsoft.Azure命名空间访问这些路径上的文件

其他详细信息:在C#/ASP.NET中,作为Azure Web应用程序部署

多谢各位

是的,这是可能的

以下是一个演示,供您参考:

我的文件共享和一个图片文件如下:

    public static void DownloadFromFileStorage()
    {
        CloudStorageAccount account = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=leeliublob;AccountKey=OxxxxxxxxQSy2vkvSi/x/e9l9FhLqayXcbxxxxxJ5Wjkly1DsQPYY5dF2JrAVHtBozbJo29ZrrGJA==;EndpointSuffix=core.windows.net");
        CloudFileClient client = account.CreateCloudFileClient();


        //get File Share
        CloudFileShare cloudFileShare = client.GetShareReference("myfile");

        //get the related directory
        CloudFileDirectory root = cloudFileShare.GetRootDirectoryReference();
        CloudFileDirectory dir = root.GetDirectoryReference("Folder1");

        //get the file reference
        CloudFile file = dir.GetFileReference("1.PNG");

        //download file to local disk
        file.DownloadToFile("C:\\Test\\1.PNG", System.IO.FileMode.OpenOrCreate);

    }

我的代码如下:

    public static void DownloadFromFileStorage()
    {
        CloudStorageAccount account = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=leeliublob;AccountKey=OxxxxxxxxQSy2vkvSi/x/e9l9FhLqayXcbxxxxxJ5Wjkly1DsQPYY5dF2JrAVHtBozbJo29ZrrGJA==;EndpointSuffix=core.windows.net");
        CloudFileClient client = account.CreateCloudFileClient();


        //get File Share
        CloudFileShare cloudFileShare = client.GetShareReference("myfile");

        //get the related directory
        CloudFileDirectory root = cloudFileShare.GetRootDirectoryReference();
        CloudFileDirectory dir = root.GetDirectoryReference("Folder1");

        //get the file reference
        CloudFile file = dir.GetFileReference("1.PNG");

        //download file to local disk
        file.DownloadToFile("C:\\Test\\1.PNG", System.IO.FileMode.OpenOrCreate);

    }
结果截图:

是的,这是可能的

以下是一个演示,供您参考:

我的文件共享和一个图片文件如下:

    public static void DownloadFromFileStorage()
    {
        CloudStorageAccount account = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=leeliublob;AccountKey=OxxxxxxxxQSy2vkvSi/x/e9l9FhLqayXcbxxxxxJ5Wjkly1DsQPYY5dF2JrAVHtBozbJo29ZrrGJA==;EndpointSuffix=core.windows.net");
        CloudFileClient client = account.CreateCloudFileClient();


        //get File Share
        CloudFileShare cloudFileShare = client.GetShareReference("myfile");

        //get the related directory
        CloudFileDirectory root = cloudFileShare.GetRootDirectoryReference();
        CloudFileDirectory dir = root.GetDirectoryReference("Folder1");

        //get the file reference
        CloudFile file = dir.GetFileReference("1.PNG");

        //download file to local disk
        file.DownloadToFile("C:\\Test\\1.PNG", System.IO.FileMode.OpenOrCreate);

    }

我的代码如下:

    public static void DownloadFromFileStorage()
    {
        CloudStorageAccount account = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=leeliublob;AccountKey=OxxxxxxxxQSy2vkvSi/x/e9l9FhLqayXcbxxxxxJ5Wjkly1DsQPYY5dF2JrAVHtBozbJo29ZrrGJA==;EndpointSuffix=core.windows.net");
        CloudFileClient client = account.CreateCloudFileClient();


        //get File Share
        CloudFileShare cloudFileShare = client.GetShareReference("myfile");

        //get the related directory
        CloudFileDirectory root = cloudFileShare.GetRootDirectoryReference();
        CloudFileDirectory dir = root.GetDirectoryReference("Folder1");

        //get the file reference
        CloudFile file = dir.GetFileReference("1.PNG");

        //download file to local disk
        file.DownloadToFile("C:\\Test\\1.PNG", System.IO.FileMode.OpenOrCreate);

    }
结果截图:


要回答这个问题,下载到文件的内容是:


file.GetFileReference(“1.PNG”).DownloadToFile(“FolderPath”,System.IO.FileMode.OpenOrCreate)

要回答这个问题,下载到文件将是:


file.GetFileReference(“1.PNG”).DownloadToFile(“FolderPath”,System.IO.FileMode.OpenOrCreate)

最简单的方法是使用 从下载
azcopy
.exe 对于windows-启动cmd并通过转到下载文件夹启动下载的.exe

cd <folder-with-azcopy.exe>
azopy.exe

最简单的方法是使用 从下载
azcopy
.exe 对于windows-启动cmd并通过转到下载文件夹启动下载的.exe

cd <folder-with-azcopy.exe>
azopy.exe

是的,可以下载这些文件。您只是在寻找示例代码吗?如果是这样的话,请查看。是否有任何更新???是的,可以下载这些文件。您只是在寻找示例代码吗?如果是这种情况,请检查此项。是否有任何更新???要使此项工作,我们是否需要预先设置名为“myfile”的文件共享?我收到一个编译错误:“IListFileItem”不包含“DownloadToFile”的防御,并且找不到接受“IListFileItem”类型的第一个参数的扩展方法“DownloadToFile”(您是否缺少using指令或程序集引用?)预设置?我收到一个编译错误:“IListFileItem”不包含“DownloadToFile”的防御,并且找不到接受“IListFileItem”类型的第一个参数的扩展方法“DownloadToFile”(是否缺少using指令或程序集引用?)当我尝试下载到文件行时,你知道为什么吗?OP是以编程的方式问的OP是以编程的方式问的