Skip to main content
The First Step
November 17, 2021
Question

MMS

Getting error in sending MMS:

IOException: The process cannot access the file 'C:UsersDELLSourceReposCosmeticsOmsOms.WebwwwrootfilesRingCentral est_4e28.jpg' because it is being used by another process.

MY CODE:

var attachment = new Attachment { fileName = model.FileName, contentType = imageType, bytes = System.IO.File.ReadAllBytes(filePathCopy) };

    2 replies

    PhongVu
    Community Manager
    Community Manager
    November 17, 2021

    Seems the file is being open by another program in your computer. This may have nothing to do with the SDK or the API. Double check it and try.

    benny-1The First StepAuthor
    The First Step
    November 17, 2021

    Thanks for reply I just upload file into folder then access file into attachment.

    var imageType = "";

    if (model.UploadedFile != null)

    {

    var directoryPath = Path.Combine(_env.WebRootPath, localDirectoryPath);

    var uniqueFileName = GetUniqueFileName(model.UploadedFile.FileName);

    imageType = model.UploadedFile.ContentType;


    var filePath = Path.Combine(directoryPath, uniqueFileName);

    model.UploadedFile.CopyTo(new FileStream(filePath, FileMode.Create));

    model.FileName = uniqueFileName;

    model.FilePath = localDirectoryPath + model.FileName;

    }


    var parameters = new CreateSMSMessage();

    parameters.from = new MessageStoreCallerInfoRequest { phoneNumber = ringCentralCredentials.Username };

    parameters.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = model.ReceiptNumber } };

    parameters.text = model.Message;

    var filePathCopy = "wwwroot/" + model.FilePath;

    var attachment = new Attachment { fileName = model.FileName, contentType = imageType, bytes = System.IO.File.ReadAllBytes(filePathCopy) };