Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace RetGet.data
- [DataMember]
- public int Id { get; set; }
- [DataMember]
- public string RetPath { get; set; }
- }
- }
- //Ref to the model
- RetFil retfil = new RetFil();
- //Network drive path (Might have to change/Access permissions)
- string dirPath = @"HERE IS THE NETWORK DRIVE PATH";
- List<string> files;
- List<object> filesFormatted;
- public void SetUpLists()
- {
- //Collects all the .ret files in the dirPath and it's subfolders.
- files = new List<string>(Directory.GetFiles(dirPath, "*.ret", SearchOption.AllDirectories));
- filesFormatted = new List<object>();
- }
- // GET: api/Ret/5
- [ResponseType(typeof(RetFil))]
- public IHttpActionResult GetRet(string id)
- {
- SetUpLists();
- //Adds each filename and format it (removing "" from the file path) to the list of objects
- foreach (var file in files)
- {
- var pathToString = file.Substring(file.LastIndexOf("\"));
- if (pathToString.Contains(id))
- {
- filesFormatted.Add(new { pathToString });
- }
- }
- //Returns the list of object. Web Api will convert to JSON automatic.
- return Ok(filesFormatted);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement