BlobSync.CommonOps.DoesFileExist C# (CSharp) Method

DoesFileExist() public static method

public static DoesFileExist ( string localFilePath ) : bool
localFilePath string
return bool
        public static bool DoesFileExist(string localFilePath)
        {
            return File.Exists(localFilePath);
        }

Usage Example

Example #1
0
        public long DownloadBlob(string containerName, string blobName, string localFilePath, int parallelFactor = 2)
        {
            long bytesDownloaded = 0;

            if (CommonOps.DoesFileExist(localFilePath))
            {
                // local file exists.
                // 1) generate sig for local file.
                // 2) download sig for blob.

                var blobSig       = DownloadSignatureForBlob(containerName, blobName);
                var localSig      = CommonOps.CreateSignatureForLocalFile(localFilePath);
                var searchResults = CommonOps.SearchLocalFileForSignatures(localFilePath, blobSig);

                // we now have a list of which blocks are already in the local file (searchResults.SignaturesToReuse)
                // We need to then determine the byteranges which are NOT covered by these blocks
                // and download those.
                // Then we need to get the blocks that already exist in the local file, read those then write them to the new file.
                var byteRangesToDownload = GenerateByteRangesOfBlobToDownload(searchResults.SignaturesToReuse, blobSig,
                                                                              containerName, blobName);

                RegenerateBlob(containerName, blobName, byteRangesToDownload, localFilePath, searchResults.SignaturesToReuse, blobSig, parallelFactor);

                foreach (var byteRange in byteRangesToDownload)
                {
                    bytesDownloaded += byteRange.EndOffset - byteRange.BeginOffset;
                }
            }
            else
            {
                // download fresh copy.
                // get stream to store.
                using (var stream = CommonHelper.GetStream(localFilePath))
                {
                    bytesDownloaded = DownloadBlob(containerName, blobName, stream, parallelFactor);
                }
            }

            return(bytesDownloaded);
        }