vivek patel

vivek patel

  • NA
  • 397
  • 10.4k

After upload file has been corrupted in rood directory

Sep 9 2020 1:28 PM
When i upload the file in root directory and then try to open but getting error-it's look like this we don't support this file format
 
Please do suggestion as per below code
  1. public async Task<ReturnInfo> UploadImage(UploadProgressArgs files)  
  2. {  
  3.     var test = new ReturnInfo();        
  4.     var outputDirectory = Path.Combine(Environment.CurrentDirectory, "TestFolder");  
  5.     Directory.CreateDirectory(outputDirectory);  
  6.     byte[] dataArray = new byte[files.Files.FirstOrDefault().Size];  
  7.     var paths = Path.Combine(Environment.CurrentDirectory, "TestFolder", files.Files.FirstOrDefault().Name);  
  8.     using (var stream = new FileStream(paths, FileMode.Create))  
  9.     {  
  10.         stream.Write(dataArray, 0, dataArray.Length);  
  11.     }  
  12. }  

Answers (1)