Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. using (StreamReader CsvReader = new StreamReader(input_file))
  2. {
  3. string inputLine = "";
  4.  
  5. while ((inputLine = CsvReader.ReadLine()) != null)
  6. {
  7. values.Add(inputLine.Trim().Replace(",", "").Replace(" ", ""));
  8. }
  9. CsvReader.Close();
  10. return values;
  11. }
  12.  
  13. if(!Request.Content.IsMimeMultipartContent())
  14. {
  15. return "|UnsupportedMediaType";
  16. }
  17.  
  18. try
  19. {
  20. var provider = new MultipartMemoryStreamProvider();
  21.  
  22. await Request.Content.LoadIntoBufferAsync().ConfigureAwait(false);
  23. await Request.Content.ReadAsMultipartAsync(provider).ConfigureAwait(false);
  24.  
  25. HttpContent content = provider.Contents.FirstOrDefault();
  26.  
  27. if(content != null)
  28. {
  29. Stream stream = await content.ReadAsStreamAsync().ConfigureAwait(false);
  30.  
  31. using (StreamReader CsvReader = new StreamReader(stream))
  32. {
  33. string inputLine = "";
  34.  
  35. while ((inputLine = CsvReader.ReadLine()) != null)
  36. {
  37. string[] vars = inputLine.Split(',');
  38.  
  39.  
  40. }
  41. CsvReader.Close();
  42. //return values;
  43. }
  44.  
  45. }
  46. }
  47. catch(Exception e)
  48. {
  49. return e.ToString();
  50. }
  51.  
  52. return "Nothing To Process";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement