0

when i upload the image or video in localpath once the media is uploaded exception is came like System.IO.FileNotFoundException: Could not find file issue not recreated our side. how to resolve this issue.

public byte[] GetBase64Stream(string ImagePath)
{
    byte[] buffer;
    FileStream fileStream = new FileStream(ImagePath, FileMode.Open, FileAccess.Read);

    try
    {
        int length = (int)fileStream.Length;  
        buffer = new byte[length];            
        int count;                           
        int sum = 0;                            
                        
        while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)
        {
            sum += count;  
        }
    }
    finally
    {
        fileStream.Close();
    }
    return buffer;
}        
        
public async Task<List<string>> UploadMedia(UnsavedMedia unsavedMedia)
{
    try
    {
        byte[] data = DependencyService.Get<ISign>().GetBase64Stream(unsavedMedia.LocalPath);
    }
}
Bijington
  • 3,661
  • 5
  • 35
  • 52
newxamarin
  • 89
  • 7
  • 1
    which specific line is throwing the exception? – Jason Jul 29 '21 at 16:20
  • DependencyService.Get().GetBase64Stream(unsavedMedia.LocalPath) these line throwing error – newxamarin Jul 29 '21 at 16:28
  • 1
    Look at the stack trace and figure out which line **inside** that method is failing. You also say this happens "once the media is uploaded" but it appears that this code is executed **before** the upload. – Jason Jul 29 '21 at 16:31
  • Failing UploadMedia Method and in dependencyservice line issue not recreated for me it only occurs user only – newxamarin Jul 29 '21 at 16:36
  • 1
    Then you need to add some logging to your app to help track down the root cause. Based on the information you've posted there is nothing else we can tell you. – Jason Jul 29 '21 at 16:38
  • "stackTrace": " at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess)\n at Droid.Signature.GetBase64Stream (System.String ImagePath) [0x00001] in <5a95ff67e15c4b08b6a285c33aeea568>:0 \n at MediaQueue.UploadMedia (UnsavedMedia unsavedMedia, System.Threading.CancellationToken token) [0x00123] in <577addc6e423440baa854fefd27368fc>:0 ", – newxamarin Jul 29 '21 at 16:44
  • this is logged in our app – newxamarin Jul 29 '21 at 16:45
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/235423/discussion-between-newxamarin-and-jason). – newxamarin Jul 29 '21 at 16:57
  • How does `UnsavedMedia` get created? From your explanation it appears that the file in `unsavedMedia.LocalPath` does not exist. – Bijington Jul 29 '21 at 18:55
  • UnsavedMedia is class and LocalPath is propertyName – newxamarin Jul 30 '21 at 07:09
  • The contents of `LocalPath` what is it and where do you get that value from? Most likely you are using a wrong path. – Cheesebaron Aug 01 '21 at 19:36

0 Answers0