I am trying to upload a file through stream to azure file share. This is my function :
public static async Task UploadFile(string shareName, Stream content, string fileName, string dirName)
{
var shareClient = Common.CreateSMBClientFromConnectionString(shareName);
ShareDirectoryClient directory = shareClient.GetDirectoryClient(dirName);
ShareFileClient file = directory.GetFileClient(fileName);
await file.CreateAsync(content.Length);
await file.UploadAsync(content);
}
I calling this function by the following command:
SMBHelper.UploadFile("filesharetester", rps, "hereischecking.txt", "checking/lp").GetAwaiter();
The program shows no error but while debugging the program I see that the pointer get lost whenever statement containing await
arrives. Like in this case program automatically stopped working when statement await file.CreateAsync(content.Length);
arrives.