I would like to create new blob on FileShareClient in Azure FileShare resource with .NET api. I cannot specify it's size in the beginning (because it will be filled with data later eg. csv file filled with lines, up to couple of GBs).
I was trying to use something like this in my code:
using Azure.Storage.Files.Shares
ShareFileClient fileShare = new ShareFileClient(
"MYConnectionString",
"FileShareName",
"TestDirectoryName");
if (!fileShare.Exists())
{
fileShare.Create(0);
}
var stream = fileShare.OpenWrite(true, 0);
[Edit] I have got an exception: System.ArgumentException: 'options.MaxSize must be set if overwrite is set to true' Is there any way to avoid specyfining this size?
Please try to use the latest package Azure.Storage.Files.Shares, version 12.5.0.
Note, in the code new ShareFileClient(), the last parameter is the directory name + file name.
see the code below:
ShareFileClient f2 = new ShareFileClient(connectionString, shareName, dirName + "/test.txt");
if (!f2.Exists())
{
f2.Create(0);
}
The file with 0 size can be created, here is the test result:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With