[英]windres: The filename, directory name, or volume label syntax is incorrect
[英]The filename, directory name or volume label is incorrect
這是我的代碼,我收到文件名/目錄不正確的錯誤。 該文件確實存在於該目錄中。 我想將此文件上傳到我的 azure blob 存儲。
private static void UploadFileToBlobStorage()
{
var localFilePath = "C:\\Users\\LK\\source\repos\dsd-ica-perf\\src\\et.ure.ica.Perf\\PerfTest.cs";
BlobServiceClient blobServiceClient = new BlobServiceClient(storageConnStr);
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("perfTest");
Console.WriteLine("Uploading to Blob storage as blob:\n\t {0}\n", blobServiceClient.Uri);
BlobClient blobClient = containerClient.GetBlobClient("PerfTest");
using FileStream uploadingFileStream = File.OpenRead(localFilePath);
blobClient.Upload(uploadingFileStream);
uploadingFileStream.Close();
}
當我嘗試使用上述代碼時,我能夠在 azure blob 存儲中成功上傳文件”
using Azure.Storage.Blobs;
namespace blobstorage
{
class Program
{
private static void Main()
{
var storageConnStr = <connection string of the storage account>;
var localFilePath = "@"C:\root"; #path of the folder which should be upto file
BlobServiceClient blobServiceClient = new BlobServiceClient(storageConnStr);
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("container1");#lowercase should be allowed.
Console.WriteLine("Uploading to Blob storage as blob:\n\t {0}\n", blobServiceClient.Uri);
BlobClient blobClient = containerClient.GetBlobClient("folder1");
using FileStream uploadingFileStream = File.OpenRead(localFilePath);
blobClient.Upload(uploadingFileStream);
uploadingFileStream.Close();
}
}
}
Azure 門戶 -> 存儲帳戶:上傳文件之前。
Output:
當我嘗試使用上述代碼時,我在 azure blob 存儲中成功上傳了一個文件。
正如@gauravmantri 在評論中所說,blob 容器名稱應該是小寫的,並且由於文件夾的路徑是錯誤的條件而發生錯誤。請檢查上面的代碼,路徑應該是這種方式。
參考:
system.io.file - C#:System.IO.DirectoryNotFoundException:'找不到路徑的一部分 - Thinbug
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.