1
votes

I am uploading a zip file on azure storage with windows service using cloudblockblob which is working fine with upload stream. But when i check into azure storage explorer, it is appending the location path at the start of zip file name like this,

C:\Users\bwadmin\Source\BusinessWorx\Connector Service v5.1\TSS_03092016_635931219970817910_470088b2-9416-e411-ae0a-6c3be5a81b54_TSSCustomers.zip

while i just want the file name there like this,

TSS_03092016_635931219970817910_470088b2-9416-e411-ae0a-6c3be5a81b54_TSSCustomers.zip

the code i am using is

using (var fileStream = System.IO.File.OpenRead(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\" + zipfilename))
            {
                blockBlob.UploadFromStream(fileStream);
            }

Any idea?

1
How are you creating an instance of block blob in your code? Please share that code.Gaurav Mantri
this is how i am creating instance CloudBlockBlob blockBlob = container.GetBlockBlobReference(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\" + zipfilename);Awais

1 Answers

2
votes

Please change the following line of code:

CloudBlockBlob blockBlob = container.GetBlockBlobReference(Path.GetDirectoryName(System.Reflection.Assembly‌​.GetEntryAssembly().Location) + "\\" + zipfilename);

to

CloudBlockBlob blockBlob = container.GetBlockBlobReference(zipfilename);

and that should take care of the problem.