I have the code below,after retrieving the file i want to convert it to json.
Any help is appreciated.
- public string DownloadDocument(string documentname, string documentlocation)
- {
- string obj = string.Empty;
- DirectoryInfo d = new DirectoryInfo(documentlocation);
- FileInfo[] Files = d.GetFiles();
- foreach (FileInfo file in Files)
- {
- if (file.Name.Contains(documentname))
- {
- //want to convert file to json as below but not working
- //obj = Newtonsoft.Json.JsonConvert.SerializeObject(file);
- }
- }
- return obj;
- }
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Amit GuptaRank #190 · 12.8K reputationPosted May 6, 2020, 7:58 AM EDT
Austin MutsRank #4,173 · 360 reputationPosted May 7, 2020, 1:00 AM EDT