2

I'm implementing IDotNetActivity while working on CustomActivity.

I want to read a file name that exists on input dataset at folder path adftutorial/customactivityinput/abc.txt, update some text and finally copy the result at output dataset adftutorial/customactivityoutput/xyz.txt.

while reading file abc.txt I'm getting System.IO.FileNotFoundException occurred in MyDotNetActivity.dll.

I'm looking help on some method which could give me complete path like <AzureCloutDirectory> + filename.

Please advise what is the best approach or the way to load text file.

Thank you!

Phani Kumar M
  • 4,564
  • 1
  • 14
  • 26

1 Answers1

0

You should give some more information (code) how do you access to the blob/blob information you need.

I can tell you that when you get blobs with BlobResultSegment blobList = inputClient.ListBlobsSegmented(...) method and iterate each one with:

        foreach (IListBlobItem listBlobItem in blobResult.Results)
        {
            var cloudBlockBlob = listBlobItem as CloudBlockBlob;
            ... // Your code here
        }

you can access complete path + filename with

cloudBlockBlob.Uri.AbsoluteUri property

== "AzureCloudDirectory/ContainerName/yourFile.txt"

Kind regards!

zoxparty
  • 63
  • 7
  • Thanks a lot for the help. It worked fine. I do have another question what is the best way to read particular file in stream. – Sandeep Choudhary Sep 20 '17 at 10:25
  • @SandeepChoudhary which stream? (Get file by its name?) – zoxparty Sep 20 '17 at 13:44
  • I have to take input file, make some modifications and then finally upload the file. I need an alternate to File.Create(outputFile) or below code. using (Stream fOut = File.Create(outputFile)) { Stream s= ld.GetInputStream(); Streams.PipeAll(s, fOut); } – Sandeep Choudhary Sep 20 '17 at 18:35
  • Just look my code up in the post. While you are in foreach, you iterate blobs , so you have possibility to to download blob like this `string file = cloudBlockBlob.DownloadText();`, but if you have binary files you should use `byte[] byteArray = new byte[cloudBlockBlob.Properties.Length]; cloudBlockBlob.DownloadToByteArray(byteArray, 0);` or even `var StreamBlob = cloudBlockBlob.DownloadToFile();` or `var StreamBlob = cloudBlockBlob.DownloadToStream();`. You can choose what suits you the best. Feel free to upvote if this answer is OK. Kind regards! – zoxparty Sep 21 '17 at 07:08