Ramco Ramco

Ramco Ramco

  • 808
  • 2.5k
  • 318k

How to pass variable value

Dec 27 2022 9:34 AM

Hi

  In below code i don't want to hardcode in request0 & client0. I have values in 2 variables

string1 = htts://nimubs-assets.s3.amazonaws.com/manifest

string2 = 20221227113803-73.pdf

How the below code should be changed

if (idx != -1)
{
    var firstPart = s.Substring(0, idx); // htts://nimubs-assets.s3.amazonaws.com/manifest
    var secondPart = s.Substring(idx + 1); // 20221227113803-73.pdf
}

var pdf0 = DateTime.Now.ToString("yyyyMMddHHmm");
var request0 = new RestRequest("/manifest/20221227113803-73.pdf", Method.GET);
var client0 = new RestClient("htps://nimubs-assets.s3.amazonaws.com");
var content = client0.DownloadData(request0);

MemoryStream ms = new MemoryStream(content);
FileStream file = new FileStream(@"D:\" + pdf0 , FileMode.Create, FileAccess.Write);
ms.WriteTo(file);
file.Close();
ms.Close();

Thanks


Answers (2)